3v4l.org

run code in 200+ PHP versions simultaneously
<?php class NonLeakingClass { protected $x=[1,2,3,4,5,6,7,8,9,10]; public function __counstruct(){ } } class NonLeakingClass2 { protected $x=[1,2,3,4,5,6,7,8,9,10]; public function __counstruct(){ } } function test($x){ $ret = []; for($i=0;$i<(1022/2)*$x;$i++){ $ret[] = new NonLeakingClass(); $ret[] = new NonLeakingClass2(); } return $ret; } for ($h = 1; $h < 5; $h++) { echo "test $h \n\n"; var_dump(memory_get_usage(false)); $a = test($h); unset($a); gc_collect_cycles(); var_dump(memory_get_usage(false)); } exit;
based on lV6mL
Finding entry points
Branch analysis from position: 0
Jump found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Jump found. (Code = 44) Position 1 = 32, Position 2 = 5
Branch analysis from position: 32
Jump found. (Code = 79) Position 1 = -2
Branch analysis from position: 5
Jump found. (Code = 44) Position 1 = 32, Position 2 = 5
Branch analysis from position: 32
Branch analysis from position: 5
filename:       /in/5ap4Z
function name:  (null)
number of ops:  34
compiled vars:  !0 = $h, !1 = $a
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
  11     1        NOP                                                      
  18     2        NOP                                                      
  28     3        ASSIGN                                                   !0, 1
         4      > JMP                                                      ->30
  29     5    >   ROPE_INIT                                     3  ~6      'test+'
         6        ROPE_ADD                                      1  ~6      ~6, !0
         7        ROPE_END                                      2  ~5      ~6, '+%0A%0A'
         8        ECHO                                                     ~5
  30     9        INIT_FCALL                                               'var_dump'
        10        INIT_FCALL                                               'memory_get_usage'
        11        SEND_VAL                                                 <false>
        12        DO_ICALL                                         $8      
        13        SEND_VAR                                                 $8
        14        DO_ICALL                                                 
  31    15        INIT_FCALL                                               'test'
        16        SEND_VAR                                                 !0
        17        DO_FCALL                                      0  $10     
        18        ASSIGN                                                   !1, $10
  32    19        UNSET_VAR                                                !1
  33    20        INIT_FCALL                                               'gc_collect_cycles'
        21        DO_ICALL                                                 
  34    22        INIT_FCALL                                               'var_dump'
        23        INIT_FCALL                                               'memory_get_usage'
        24        SEND_VAL                                                 <false>
        25        DO_ICALL                                         $13     
        26        SEND_VAR                                                 $13
        27        DO_ICALL                                                 
  28    28        POST_INC                                         ~15     !0
        29        FREE                                                     ~15
        30    >   IS_SMALLER                                       ~16     !0, 5
        31      > JMPNZ                                                    ~16, ->5
  37    32    > > EXIT                                                     
  38    33*     > RETURN                                                   1

Function test:
Finding entry points
Branch analysis from position: 0
Jump found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Jump found. (Code = 44) Position 1 = 17, Position 2 = 4
Branch analysis from position: 17
Jump found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
Jump found. (Code = 44) Position 1 = 17, Position 2 = 4
Branch analysis from position: 17
Branch analysis from position: 4
filename:       /in/5ap4Z
function name:  test
number of ops:  19
compiled vars:  !0 = $x, !1 = $ret, !2 = $i
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  18     0  E >   RECV                                             !0      
  19     1        ASSIGN                                                   !1, <array>
  20     2        ASSIGN                                                   !2, 0
         3      > JMP                                                      ->14
  21     4    >   NEW                                              $6      :-3
         5        DO_FCALL                                      0          
         6        ASSIGN_DIM                                               !1
         7        OP_DATA                                                  $6
  22     8        NEW                                              $9      :-1
         9        DO_FCALL                                      0          
        10        ASSIGN_DIM                                               !1
        11        OP_DATA                                                  $9
  20    12        POST_INC                                         ~11     !2
        13        FREE                                                     ~11
        14    >   MUL                                              ~12     511, !0
        15        IS_SMALLER                                       ~13     !2, ~12
        16      > JMPNZ                                                    ~13, ->4
  24    17    > > RETURN                                                   !1
  26    18*     > RETURN                                                   null

End of function test

Class NonLeakingClass:
Function __counstruct:
Finding entry points
Branch analysis from position: 0
Jump found. (Code = 62) Position 1 = -2
filename:       /in/5ap4Z
function name:  __counstruct
number of ops:  1
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   8     0  E > > RETURN                                                   null

End of function __counstruct

End of class NonLeakingClass.

Class NonLeakingClass2:
Function __counstruct:
Finding entry points
Branch analysis from position: 0
Jump found. (Code = 62) Position 1 = -2
filename:       /in/5ap4Z
function name:  __counstruct
number of ops:  1
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  16     0  E > > RETURN                                                   null

End of function __counstruct

End of class NonLeakingClass2.

Generated using Vulcan Logic Dumper, using php 7.3.0