3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Collection extends ArrayObject { protected $iterator; public function getIterator() { // Well, this is a heavy object to make, let's memoize it if (!isset($this->iterator)) { $this->iterator = new ArrayIterator($this); } return $this->iterator; } } function foo() { $collection = new Collection(array( 'foo', 'bar' )); foreach ($collection as $item) { break; } unset($collection); } gc_enable(); $base = memory_get_usage(); foreach (range(1, 250000) as $i) { foo(); gc_collect_cycles(); if ($i % 500 === 0) { var_dump(memory_get_usage() - $base); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 25
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 25
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 24
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 24
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/WQWqP
function name:  (null)
number of ops:  27
compiled vars:  !0 = $base, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_FCALL                                               'gc_enable'
          1        DO_ICALL                                                 
   28     2        INIT_FCALL                                               'memory_get_usage'
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !0, $3
   30     5        INIT_FCALL                                               'range'
          6        SEND_VAL                                                 1
          7        SEND_VAL                                                 250000
          8        DO_ICALL                                         $5      
          9      > FE_RESET_R                                       $6      $5, ->25
         10    > > FE_FETCH_R                                               $6, !1, ->25
   31    11    >   INIT_FCALL                                               'foo'
         12        DO_FCALL                                      0          
   33    13        INIT_FCALL                                               'gc_collect_cycles'
         14        DO_ICALL                                                 
   35    15        MOD                                              ~9      !1, 500
         16        IS_IDENTICAL                                             ~9, 0
         17      > JMPZ                                                     ~10, ->24
   36    18    >   INIT_FCALL                                               'var_dump'
         19        INIT_FCALL                                               'memory_get_usage'
         20        DO_ICALL                                         $11     
         21        SUB                                              ~12     $11, !0
         22        SEND_VAL                                                 ~12
         23        DO_ICALL                                                 
   30    24    > > JMP                                                      ->10
         25    >   FE_FREE                                                  $6
   38    26      > RETURN                                                   1

Function foo:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
Branch analysis from position: 8
filename:       /in/WQWqP
function name:  foo
number of ops:  11
compiled vars:  !0 = $collection, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   NEW                                              $2      'Collection'
          1        SEND_VAL_EX                                              <array>
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   19     4      > FE_RESET_R                                       $5      !0, ->8
          5    > > FE_FETCH_R                                               $5, !1, ->8
   20     6    > > JMP                                                      ->8
   19     7*       JMP                                                      ->5
          8    >   FE_FREE                                                  $5
   23     9        UNSET_CV                                                 !0
   24    10      > RETURN                                                   null

End of function foo

Class Collection:
Function getiterator:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/WQWqP
function name:  getIterator
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ISSET_ISEMPTY_PROP_OBJ                           ~0      'iterator'
          1        BOOL_NOT                                         ~1      ~0
          2      > JMPZ                                                     ~1, ->9
    9     3    >   NEW                                              $3      'ArrayIterator'
          4        FETCH_THIS                                       $4      
          5        SEND_VAR_EX                                              $4
          6        DO_FCALL                                      0          
          7        ASSIGN_OBJ                                               'iterator'
          8        OP_DATA                                                  $3
   12     9    >   FETCH_OBJ_R                                      ~6      'iterator'
         10      > RETURN                                                   ~6
   13    11*     > RETURN                                                   null

End of function getiterator

End of class Collection.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.15 ms | 1394 KiB | 24 Q