3v4l.org

run code in 300+ PHP versions simultaneously
<?php // makes a big map $map = []; for($a = 0; $a < 55555; $a++){ $map["key" . $a] = (object)(array)["x" => $a]; } // empty the map (or partially empty it) for($a = 0; $a < 55555; $a++){ unset($map["key" . $a]); } // at this point $map's length is nexPow2(55555), even if it is empty $om = memory_get_usage(); echo $om . "\n"; (function(array $map){ $map["sup"] = "copy"; // copy on write allocates another nexPow2(55555) array, // rather than starting with a small one $nm = memory_get_usage(); echo $nm . "\n"; })($map);

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 3
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 14
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 14
Branch analysis from position: 19
Branch analysis from position: 14
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 3
Branch analysis from position: 12
Branch analysis from position: 3
filename:       /in/Manqu
function name:  (null)
number of ops:  29
compiled vars:  !0 = $map, !1 = $a, !2 = $om
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->10
    6     3    >   CONCAT                                           ~5      'key', !1
          4        INIT_ARRAY                                       ~7      !1, 'x'
          5        CAST                                          7  ~8      ~7
          6        CAST                                          8  ~9      ~8
          7        ASSIGN_DIM                                               !0, ~5
          8        OP_DATA                                                  ~9
    5     9        PRE_INC                                                  !1
         10    >   IS_SMALLER                                               !1, 55555
         11      > JMPNZ                                                    ~11, ->3
   10    12    >   ASSIGN                                                   !1, 0
         13      > JMP                                                      ->17
   11    14    >   CONCAT                                           ~13     'key', !1
         15        UNSET_DIM                                                !0, ~13
   10    16        PRE_INC                                                  !1
         17    >   IS_SMALLER                                               !1, 55555
         18      > JMPNZ                                                    ~15, ->14
   16    19    >   INIT_FCALL                                               'memory_get_usage'
         20        DO_ICALL                                         $16     
         21        ASSIGN                                                   !2, $16
   17    22        CONCAT                                           ~18     !2, '%0A'
         23        ECHO                                                     ~18
   19    24        DECLARE_LAMBDA_FUNCTION                          ~19     [0]
   27    25        INIT_DYNAMIC_CALL                                        ~19
         26        SEND_VAR_EX                                              !0
         27        DO_FCALL                                      0          
         28      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Manqu
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $map, !1 = $nm
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        ASSIGN_DIM                                               !0, 'sup'
          2        OP_DATA                                                  'copy'
   25     3        INIT_FCALL                                               'memory_get_usage'
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
   26     6        CONCAT                                           ~5      !1, '%0A'
          7        ECHO                                                     ~5
   27     8      > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.65 ms | 1005 KiB | 14 Q