3v4l.org

run code in 500+ PHP versions simultaneously
<?php gc_enable(); $arr = []; getMemory(); for ($i = 0; $i < 5000; $i++) { $d = str_repeat("Hello, world!", 400); $arr[$i][] = $d; } // Clear the sub-arrays foreach (array_keys($arr) as $index) { unset($arr[$index]); } // Clear the sub-arrays foreach ($arr as &$subArray) { unset($subArray); } array_splice($arr, 0); // Remove all elements from the main array unset($arr); gc_collect_cycles(); getMemory(); function getMemory() { echo date("Y-m-d H:i:s") . ' :: ' . round( (memory_get_usage(true) / 1000000), 2 ) . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 7
Branch analysis from position: 18
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 25
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 25
2 jumps found. (Code = 125) Position 1 = 27, Position 2 = 30
Branch analysis from position: 27
2 jumps found. (Code = 126) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
Branch analysis from position: 25
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 7
Branch analysis from position: 18
Branch analysis from position: 7
filename:       /in/l6N9I
function name:  (null)
number of ops:  41
compiled vars:  !0 = $arr, !1 = $i, !2 = $d, !3 = $index, !4 = $subArray
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                                   'gc_enable'
          1        DO_ICALL                                                     
    3     2        ASSIGN                                                       !0, <array>
    4     3        INIT_FCALL_BY_NAME                                           'getMemory'
          4        DO_FCALL                                          0          
    5     5        ASSIGN                                                       !1, 0
          6      > JMP                                                          ->16
    6     7    >   INIT_FCALL                                                   'str_repeat'
          8        SEND_VAL                                                     'Hello%2C+world%21'
          9        SEND_VAL                                                     400
         10        DO_ICALL                                             $9      
         11        ASSIGN                                                       !2, $9
    7    12        FETCH_DIM_W                                          $11     !0, !1
         13        ASSIGN_DIM                                                   $11
         14        OP_DATA                                                      !2
    5    15        PRE_INC                                                      !1
         16    >   IS_SMALLER                                                   !1, 5000
         17      > JMPNZ                                                        ~14, ->7
   11    18    >   INIT_FCALL                                                   'array_keys'
         19        SEND_VAR                                                     !0
         20        DO_ICALL                                             $15     
         21      > FE_RESET_R                                           $16     $15, ->25
         22    > > FE_FETCH_R                                                   $16, !3, ->25
   12    23    >   UNSET_DIM                                                    !0, !3
   11    24      > JMP                                                          ->22
         25    >   FE_FREE                                                      $16
   16    26      > FE_RESET_RW                                          $17     !0, ->30
         27    > > FE_FETCH_RW                                                  $17, !4, ->30
   17    28    >   UNSET_CV                                                     !4
   16    29      > JMP                                                          ->27
         30    >   FE_FREE                                                      $17
   20    31        INIT_FCALL                                                   'array_splice'
         32        SEND_REF                                                     !0
         33        SEND_VAL                                                     0
         34        DO_ICALL                                                     
   21    35        UNSET_CV                                                     !0
   22    36        INIT_FCALL                                                   'gc_collect_cycles'
         37        DO_ICALL                                                     
   23    38        INIT_FCALL_BY_NAME                                           'getMemory'
         39        DO_FCALL                                          0          
   30    40      > RETURN                                                       1

Function getmemory:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l6N9I
function name:  getMemory
number of ops:  16
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   26     0  E >   INIT_FCALL                                                   'date'
          1        SEND_VAL                                                     'Y-m-d+H%3Ai%3As'
          2        DO_ICALL                                             $0      
          3        CONCAT                                               ~1      $0, '+%3A%3A+'
          4        INIT_FCALL                                                   'round'
   27     5        INIT_FCALL                                                   'memory_get_usage'
          6        SEND_VAL                                                     <true>
          7        DO_ICALL                                             $2      
          8        DIV                                                  ~3      $2, 1000000
          9        SEND_VAL                                                     ~3
   28    10        SEND_VAL                                                     2
   26    11        DO_ICALL                                             $4      
   28    12        CONCAT                                               ~5      ~1, $4
   29    13        CONCAT                                               ~6      ~5, '%0A'
         14        ECHO                                                         ~6
   30    15      > RETURN                                                       null

End of function getmemory

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
131.83 ms | 492 KiB | 15 Q