3v4l.org

run code in 300+ PHP versions simultaneously
<?php $j = 1; var_dump(memory_get_usage()); $tipi = array_fill(0, 10000, 'php-internal'); var_dump(memory_get_usage()); //内存没有发生暴增, 没有复制, 只是引用 $tipi_copy = $tipi; var_dump(memory_get_usage()); //内存没有发生暴增, 没有复制, 仍然只是引用 foreach($tipi_copy as $value){ $j += count($value); } var_dump(memory_get_usage()); //内存发生暴增, 发生复制, 不在引用 $tipi_copy[0] = "php-internals-tmp"; var_dump(memory_get_usage());
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 28
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 28
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/F0fC4
function name:  (null)
number of ops:  42
compiled vars:  !0 = $j, !1 = $tipi, !2 = $tipi_copy, !3 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 1
    4     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'memory_get_usage'
          3        DO_ICALL                                         $5      
          4        SEND_VAR                                                 $5
          5        DO_ICALL                                                 
    6     6        INIT_FCALL                                               'array_fill'
          7        SEND_VAL                                                 0
          8        SEND_VAL                                                 10000
          9        SEND_VAL                                                 'php-internal'
         10        DO_ICALL                                         $7      
         11        ASSIGN                                                   !1, $7
    7    12        INIT_FCALL                                               'var_dump'
         13        INIT_FCALL                                               'memory_get_usage'
         14        DO_ICALL                                         $9      
         15        SEND_VAR                                                 $9
         16        DO_ICALL                                                 
   10    17        ASSIGN                                                   !2, !1
   11    18        INIT_FCALL                                               'var_dump'
         19        INIT_FCALL                                               'memory_get_usage'
         20        DO_ICALL                                         $12     
         21        SEND_VAR                                                 $12
         22        DO_ICALL                                                 
   14    23      > FE_RESET_R                                       $14     !2, ->28
         24    > > FE_FETCH_R                                               $14, !3, ->28
   15    25    >   COUNT                                            ~15     !3
         26        ASSIGN_OP                                     1          !0, ~15
   14    27      > JMP                                                      ->24
         28    >   FE_FREE                                                  $14
   17    29        INIT_FCALL                                               'var_dump'
         30        INIT_FCALL                                               'memory_get_usage'
         31        DO_ICALL                                         $17     
         32        SEND_VAR                                                 $17
         33        DO_ICALL                                                 
   20    34        ASSIGN_DIM                                               !2, 0
         35        OP_DATA                                                  'php-internals-tmp'
   21    36        INIT_FCALL                                               'var_dump'
         37        INIT_FCALL                                               'memory_get_usage'
         38        DO_ICALL                                         $20     
         39        SEND_VAR                                                 $20
         40        DO_ICALL                                                 
         41      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.86 ms | 1404 KiB | 19 Q