3v4l.org

run code in 300+ PHP versions simultaneously
<?php function by_return($dummy=null) { $dummy = str_repeat("1",10 * 1024 * 1024); return $dummy; } function by_reference(&$dummy) { $dummy = null; $dummy = str_repeat("1",10 * 1024 * 1024); } echo memory_get_usage()."/".memory_get_peak_usage()."\n"; //1 always returns: 105493696/105496656 $nagid = by_return(); echo memory_get_usage()."/".memory_get_peak_usage()."\n"; unset($nagid); //2 always returns: 105493696/210354184 even if we comment 1st part by_reference($dummy); echo memory_get_usage()."/".memory_get_peak_usage()."\n"; unset($dummy);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DA8K1
function name:  (null)
number of ops:  33
compiled vars:  !0 = $nagid, !1 = $dummy
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'memory_get_usage'
          1        DO_ICALL                                         $2      
          2        CONCAT                                           ~3      $2, '%2F'
          3        INIT_FCALL                                               'memory_get_peak_usage'
          4        DO_ICALL                                         $4      
          5        CONCAT                                           ~5      ~3, $4
          6        CONCAT                                           ~6      ~5, '%0A'
          7        ECHO                                                     ~6
   14     8        INIT_FCALL                                               'by_return'
          9        DO_FCALL                                      0  $7      
         10        ASSIGN                                                   !0, $7
   15    11        INIT_FCALL                                               'memory_get_usage'
         12        DO_ICALL                                         $9      
         13        CONCAT                                           ~10     $9, '%2F'
         14        INIT_FCALL                                               'memory_get_peak_usage'
         15        DO_ICALL                                         $11     
         16        CONCAT                                           ~12     ~10, $11
         17        CONCAT                                           ~13     ~12, '%0A'
         18        ECHO                                                     ~13
   16    19        UNSET_CV                                                 !0
   18    20        INIT_FCALL                                               'by_reference'
         21        SEND_REF                                                 !1
         22        DO_FCALL                                      0          
   19    23        INIT_FCALL                                               'memory_get_usage'
         24        DO_ICALL                                         $15     
         25        CONCAT                                           ~16     $15, '%2F'
         26        INIT_FCALL                                               'memory_get_peak_usage'
         27        DO_ICALL                                         $17     
         28        CONCAT                                           ~18     ~16, $17
         29        CONCAT                                           ~19     ~18, '%0A'
         30        ECHO                                                     ~19
   20    31        UNSET_CV                                                 !1
         32      > RETURN                                                   1

Function by_return:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DA8K1
function name:  by_return
number of ops:  8
compiled vars:  !0 = $dummy
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV_INIT                                        !0      null
    4     1        INIT_FCALL                                               'str_repeat'
          2        SEND_VAL                                                 '1'
          3        SEND_VAL                                                 10485760
          4        DO_ICALL                                         $1      
          5        ASSIGN                                                   !0, $1
    5     6      > RETURN                                                   !0
    6     7*     > RETURN                                                   null

End of function by_return

Function by_reference:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DA8K1
function name:  by_reference
number of ops:  8
compiled vars:  !0 = $dummy
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        ASSIGN                                                   !0, null
   10     2        INIT_FCALL                                               'str_repeat'
          3        SEND_VAL                                                 '1'
          4        SEND_VAL                                                 10485760
          5        DO_ICALL                                         $2      
          6        ASSIGN                                                   !0, $2
   11     7      > RETURN                                                   null

End of function by_reference

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.37 ms | 1403 KiB | 21 Q