3v4l.org

run code in 300+ PHP versions simultaneously
<?php $memoryLimit = ini_get('memory_limit'); header('Content-Type: text/plain'); echo 'Reported memory limit is: ' . $memoryLimit . PHP_EOL; $memoryTarget = 0; // Attempt to massage out what this memory limit really is if (substr($memoryLimit, -1, 1) == 'M') { // MEGA $memoryTarget = substr($memoryLimit, 0, -1) * 1024 * 1024; } else if (substr($memoryLimit, -1, 1) == 'K') { // KILO } else { echo 'Sorry script does not support the memory limit'; exit; } echo $memoryTarget; $memoryBase = round(memory_get_usage() / 1024 / 1024, 2); echo 'Base point -> ' . memory_get_usage() . ' (' . $memoryBase . ' MB)' . PHP_EOL; $pattern = str_repeat('0123456789', 1000); $fill = str_repeat($pattern, 1); $counter = 1000; while ( $counter <= $memoryTarget / 10000) { unset($fill); $memoryBase = round(memory_get_usage() / 1024 / 1024, 2); echo 'Clear -> ' . memory_get_usage() . ' (' . $memoryBase . ' MB)' . PHP_EOL; echo $counter . ' x 1000 chars -> '; $fill = str_repeat($pattern, $counter); $memoryBase = round(memory_get_usage() / 1024 / 1024, 2); echo memory_get_usage() . ' (' . $memoryBase . ' MB)'. ' [' . $memory_pct = round($memoryBase / ($memoryTarget / 1024/1024) *100 , 1) . ' percent]' . PHP_EOL; $counter += 500; } echo PHP_EOL . 'If you can see this, the server allocated something close to ' . $memoryTarget . ' bytes' . PHP_EOL;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 27
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 121
Branch analysis from position: 121
2 jumps found. (Code = 44) Position 1 = 124, Position 2 = 67
Branch analysis from position: 124
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 67
2 jumps found. (Code = 44) Position 1 = 124, Position 2 = 67
Branch analysis from position: 124
Branch analysis from position: 67
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 35
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 35
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/D64l1
function name:  (null)
number of ops:  129
compiled vars:  !0 = $memoryLimit, !1 = $memoryTarget, !2 = $memoryBase, !3 = $pattern, !4 = $fill, !5 = $counter, !6 = $memory_pct
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'ini_get'
          1        SEND_VAL                                                 'memory_limit'
          2        DO_ICALL                                         $7      
          3        ASSIGN                                                   !0, $7
    5     4        INIT_FCALL                                               'header'
          5        SEND_VAL                                                 'Content-Type%3A+text%2Fplain'
          6        DO_ICALL                                                 
    7     7        CONCAT                                           ~10     'Reported+memory+limit+is%3A+', !0
          8        CONCAT                                           ~11     ~10, '%0A'
          9        ECHO                                                     ~11
   10    10        ASSIGN                                                   !1, 0
   13    11        INIT_FCALL                                               'substr'
         12        SEND_VAR                                                 !0
         13        SEND_VAL                                                 -1
         14        SEND_VAL                                                 1
         15        DO_ICALL                                         $13     
         16        IS_EQUAL                                                 $13, 'M'
         17      > JMPZ                                                     ~14, ->27
   15    18    >   INIT_FCALL                                               'substr'
         19        SEND_VAR                                                 !0
         20        SEND_VAL                                                 0
         21        SEND_VAL                                                 -1
         22        DO_ICALL                                         $15     
         23        MUL                                              ~16     $15, 1024
         24        MUL                                              ~17     ~16, 1024
         25        ASSIGN                                                   !1, ~17
         26      > JMP                                                      ->37
   16    27    >   INIT_FCALL                                               'substr'
         28        SEND_VAR                                                 !0
         29        SEND_VAL                                                 -1
         30        SEND_VAL                                                 1
         31        DO_ICALL                                         $19     
         32        IS_EQUAL                                                 $19, 'K'
         33      > JMPZ                                                     ~20, ->35
         34    > > JMP                                                      ->37
   19    35    >   ECHO                                                     'Sorry+script+does+not+support+the+memory+limit'
   20    36      > EXIT                                                     
   24    37    >   ECHO                                                     !1
   26    38        INIT_FCALL                                               'round'
         39        INIT_FCALL                                               'memory_get_usage'
         40        DO_ICALL                                         $21     
         41        DIV                                              ~22     $21, 1024
         42        DIV                                              ~23     ~22, 1024
         43        SEND_VAL                                                 ~23
         44        SEND_VAL                                                 2
         45        DO_ICALL                                         $24     
         46        ASSIGN                                                   !2, $24
   27    47        INIT_FCALL                                               'memory_get_usage'
         48        DO_ICALL                                         $26     
         49        CONCAT                                           ~27     'Base+point+-%3E+', $26
         50        CONCAT                                           ~28     ~27, '+%28'
         51        CONCAT                                           ~29     ~28, !2
         52        CONCAT                                           ~30     ~29, '+MB%29'
         53        CONCAT                                           ~31     ~30, '%0A'
         54        ECHO                                                     ~31
   30    55        INIT_FCALL                                               'str_repeat'
         56        SEND_VAL                                                 '0123456789'
         57        SEND_VAL                                                 1000
         58        DO_ICALL                                         $32     
         59        ASSIGN                                                   !3, $32
   31    60        INIT_FCALL                                               'str_repeat'
         61        SEND_VAR                                                 !3
         62        SEND_VAL                                                 1
         63        DO_ICALL                                         $34     
         64        ASSIGN                                                   !4, $34
   32    65        ASSIGN                                                   !5, 1000
   34    66      > JMP                                                      ->121
   35    67    >   UNSET_CV                                                 !4
   36    68        INIT_FCALL                                               'round'
         69        INIT_FCALL                                               'memory_get_usage'
         70        DO_ICALL                                         $37     
         71        DIV                                              ~38     $37, 1024
         72        DIV                                              ~39     ~38, 1024
         73        SEND_VAL                                                 ~39
         74        SEND_VAL                                                 2
         75        DO_ICALL                                         $40     
         76        ASSIGN                                                   !2, $40
   37    77        INIT_FCALL                                               'memory_get_usage'
         78        DO_ICALL                                         $42     
         79        CONCAT                                           ~43     'Clear+-%3E+', $42
         80        CONCAT                                           ~44     ~43, '+%28'
         81        CONCAT                                           ~45     ~44, !2
         82        CONCAT                                           ~46     ~45, '+MB%29'
         83        CONCAT                                           ~47     ~46, '%0A'
         84        ECHO                                                     ~47
   39    85        CONCAT                                           ~48     !5, '+x+1000+chars+-%3E+'
         86        ECHO                                                     ~48
   40    87        INIT_FCALL                                               'str_repeat'
         88        SEND_VAR                                                 !3
         89        SEND_VAR                                                 !5
         90        DO_ICALL                                         $49     
         91        ASSIGN                                                   !4, $49
   41    92        INIT_FCALL                                               'round'
         93        INIT_FCALL                                               'memory_get_usage'
         94        DO_ICALL                                         $51     
         95        DIV                                              ~52     $51, 1024
         96        DIV                                              ~53     ~52, 1024
         97        SEND_VAL                                                 ~53
         98        SEND_VAL                                                 2
         99        DO_ICALL                                         $54     
        100        ASSIGN                                                   !2, $54
   42   101        INIT_FCALL                                               'memory_get_usage'
        102        DO_ICALL                                         $56     
        103        CONCAT                                           ~57     $56, '+%28'
        104        CONCAT                                           ~58     ~57, !2
        105        CONCAT                                           ~59     ~58, '+MB%29'
        106        CONCAT                                           ~60     ~59, '+%5B'
        107        INIT_FCALL                                               'round'
        108        DIV                                              ~61     !1, 1024
        109        DIV                                              ~62     ~61, 1024
        110        DIV                                              ~63     !2, ~62
        111        MUL                                              ~64     ~63, 100
        112        SEND_VAL                                                 ~64
        113        SEND_VAL                                                 1
        114        DO_ICALL                                         $65     
        115        CONCAT                                           ~66     $65, '+percent%5D'
        116        CONCAT                                           ~67     ~66, '%0A'
        117        ASSIGN                                           ~68     !6, ~67
        118        CONCAT                                           ~69     ~60, ~68
        119        ECHO                                                     ~69
   44   120        ASSIGN_OP                                     1          !5, 500
   34   121    >   DIV                                              ~71     !1, 10000
        122        IS_SMALLER_OR_EQUAL                                      !5, ~71
        123      > JMPNZ                                                    ~72, ->67
   47   124    >   CONCAT                                           ~73     '%0AIf+you+can+see+this%2C+the+server+allocated+something+close+to+', !1
        125        CONCAT                                           ~74     ~73, '+bytes'
        126        CONCAT                                           ~75     ~74, '%0A'
        127        ECHO                                                     ~75
        128      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.2 ms | 1396 KiB | 25 Q