Skip to content

Instantly share code, notes, and snippets.

@m6w6
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m6w6/b4273c3a02ef181fcff6 to your computer and use it in GitHub Desktop.
Save m6w6/b4273c3a02ef181fcff6 to your computer and use it in GitHub Desktop.
gc array/object order
█ mike@smugmug:~/build/php-master-dbg-zts$ sapi/cli/php -r '$m[]=new http\Message; $m[]=new http\Message; $m[0]->prepend($m[1]);'
[0x7ff805a58180] rc=1 addr=0 black array(1) ->purple
[0x7ff805a82128] rc=1 addr=0 black object(http\Message)#1 ->purple
[0x7ff805a82228] rc=1 addr=0 black object(http\Message)#2 ->purple
[0x7ff805a58060] rc=1 addr=0 black array(0) ->purple
[0x7ff805a58000] rc=1 addr=0 black array(0) ->purple
[0x7ff805a580c0] rc=1 addr=0 black array(0) ->purple
[0x7ff805a581e0] rc=1 addr=0 black array(86) ->purple
[0x7ff805a58120] rc=1 addr=0 black array(0) ->purple
[0x7ff805a82128] rc=0 addr=2 purple object(http\Message)#1 ->purple
[0x7ff805a82228] rc=0 addr=3 purple object(http\Message)#2 ->purple
[0x7ff805a581e0] rc=0 addr=7 purple array(86) ->purple
[0x7ff805a58180] rc=0 addr=1 purple array(1) ->purple
[0x7ff805a58120] rc=0 addr=8 purple array(0) ->purple
[0x7ff805a580c0] rc=0 addr=6 purple array(0) ->purple
[0x7ff805a58060] rc=0 addr=4 purple array(0) ->purple
[0x7ff805a58000] rc=0 addr=5 purple array(0) ->purple
█ mike@smugmug:~/build/php-master-dbg-zts$ sapi/cli/php -r '$m[]=new http\Message; $m[]=new http\Message; $m[1]->prepend($m[0]);'
[0x7f206fa58180] rc=1 addr=0 black array(1) ->purple
[0x7f206fa82128] rc=1 addr=0 black object(http\Message)#1 ->purple
[0x7f206fa82228] rc=1 addr=0 black object(http\Message)#2 ->purple
[0x7f206fa58060] rc=1 addr=0 black array(0) ->purple
[0x7f206fa58000] rc=1 addr=0 black array(0) ->purple
[0x7f206fa580c0] rc=1 addr=0 black array(0) ->purple
[0x7f206fa581e0] rc=1 addr=0 black array(86) ->purple
[0x7f206fa58120] rc=1 addr=0 black array(0) ->purple
[0x7f206fa82228] rc=0 addr=3 purple object(http\Message)#2 ->purple
[0x7f206fa581e0] rc=0 addr=7 purple array(86) ->purple
[0x7f206fa58180] rc=0 addr=1 purple array(1) ->purple
[0x7f206fa58120] rc=0 addr=8 purple array(0) ->purple
[0x7f206fa580c0] rc=0 addr=6 purple array(0) ->purple
[0x7f206fa58060] rc=0 addr=4 purple array(0) ->purple
[0x7f206fa58000] rc=0 addr=5 purple array(0) ->purple
Collecting cycles
Marking roots
[0x7f206fa82128] rc=0 addr=2 purple object(http\Message)#1 ->grey
[0x7f206fa71dc0] rc=0 addr=0 black string ->grey
[0x7f206fa58060] rc=0 addr=0 black array(0) ->grey
Scanning roots
[0x7f206fa82128] rc=0 addr=2 grey object(http\Message)#1 ->white
Collecting roots
[0x7f206fa82128] rc=1 addr=2 white object(http\Message)#1 ->black
Destroying zvals
[0x7f206fa82128] rc=1 addr=2 black object(http\Message)#1 destroying
Collection finished
[Fri Jun 12 13:24:54 2015] Script: '-'
/home/mike/src/php-master/Zend/zend_API.c(1093) : Freeing 0x7F206FA58060 (56 bytes), script=-
Last leak repeated 1 time
[Fri Jun 12 13:24:54 2015] Script: '-'
/home/mike/src/php-master/ext/http/php_http_misc.h(157) : Freeing 0x7F206FA71DC0 (35 bytes), script=-
Last leak repeated 1 time
=== Total 4 memory leaks detected ===
█ mike@smugmug:~/build/php-master-dbg-zts$ memcheck sapi/cli/php -r '$m[]=new http\Message; $m[]=new http\Message; $m[0]->prepend($m[1]);'
==4279== Memcheck, a memory error detector
==4279== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==4279== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==4279== Command: sapi/cli/php -r $m[]=new\ http\\Message;\ $m[]=new\ http\\Message;\ $m[0]-\>prepend($m[1]);
==4279==
==4279==
==4279== HEAP SUMMARY:
==4279== in use at exit: 1,054 bytes in 23 blocks
==4279== total heap usage: 20,776 allocs, 20,753 frees, 2,418,276 bytes allocated
==4279==
==4279== LEAK SUMMARY:
==4279== definitely lost: 0 bytes in 0 blocks
==4279== indirectly lost: 0 bytes in 0 blocks
==4279== possibly lost: 0 bytes in 0 blocks
==4279== still reachable: 1,054 bytes in 23 blocks
==4279== suppressed: 0 bytes in 0 blocks
==4279== Reachable blocks (those to which a pointer was found) are not shown.
==4279== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==4279==
==4279== For counts of detected and suppressed errors, rerun with: -v
==4279== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
█ mike@smugmug:~/build/php-master-dbg-zts$ memcheck sapi/cli/php -r '$m[]=new http\Message; $m[]=new http\Message; $m[1]->prepend($m[0]);'
==4313== Memcheck, a memory error detector
==4313== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==4313== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==4313== Command: sapi/cli/php -r $m[]=new\ http\\Message;\ $m[]=new\ http\\Message;\ $m[1]-\>prepend($m[0]);
==4313==
==4313==
==4313== HEAP SUMMARY:
==4313== in use at exit: 1,236 bytes in 27 blocks
==4313== total heap usage: 20,787 allocs, 20,760 frees, 2,419,418 bytes allocated
==4313==
==4313== 35 bytes in 1 blocks are definitely lost in loss record 12 of 27
==4313== at 0x4C2C29E: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4313== by 0x871F21: _erealloc (zend_alloc.c:2233)
==4313== by 0x7EFD6A: php_http_cs2zs (php_http_misc.h:157)
==4313== by 0x7F30CF: php_http_message_object_get_props (php_http_message.c:922)
==4313== by 0x8E82D6: zend_std_get_gc (zend_object_handlers.c:126)
==4313== by 0x8D53DB: gc_mark_grey (zend_gc.c:425)
==4313== by 0x8D5782: gc_mark_roots (zend_gc.c:524)
==4313== by 0x8D6860: zend_gc_collect_cycles (zend_gc.c:996)
==4313== by 0x88A773: shutdown_executor (zend_execute_API.c:336)
==4313== by 0x8A2B03: zend_deactivate (zend.c:964)
==4313== by 0x815EA4: php_request_shutdown (main.c:1814)
==4313== by 0x963775: do_cli (php_cli.c:1135)
==4313== by 0x963E53: main (php_cli.c:1334)
==4313==
==4313== 35 bytes in 1 blocks are definitely lost in loss record 13 of 27
==4313== at 0x4C2C29E: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4313== by 0x871F21: _erealloc (zend_alloc.c:2233)
==4313== by 0x7EFD6A: php_http_cs2zs (php_http_misc.h:157)
==4313== by 0x7F30CF: php_http_message_object_get_props (php_http_message.c:922)
==4313== by 0x8E82D6: zend_std_get_gc (zend_object_handlers.c:126)
==4313== by 0x8D5EE2: gc_collect_white (zend_gc.c:731)
==4313== by 0x8D62E4: gc_collect_roots (zend_gc.c:846)
==4313== by 0x8D6880: zend_gc_collect_cycles (zend_gc.c:1007)
==4313== by 0x88A773: shutdown_executor (zend_execute_API.c:336)
==4313== by 0x8A2B03: zend_deactivate (zend.c:964)
==4313== by 0x815EA4: php_request_shutdown (main.c:1814)
==4313== by 0x963775: do_cli (php_cli.c:1135)
==4313== by 0x963E53: main (php_cli.c:1334)
==4313==
==4313== 56 bytes in 1 blocks are definitely lost in loss record 24 of 27
==4313== at 0x4C29F90: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4313== by 0x871E2E: _emalloc (zend_alloc.c:2211)
==4313== by 0x8A9609: _array_init (zend_API.c:1093)
==4313== by 0x7F3A32: php_http_message_object_get_props (php_http_message.c:954)
==4313== by 0x8E82D6: zend_std_get_gc (zend_object_handlers.c:126)
==4313== by 0x8D53DB: gc_mark_grey (zend_gc.c:425)
==4313== by 0x8D5782: gc_mark_roots (zend_gc.c:524)
==4313== by 0x8D6860: zend_gc_collect_cycles (zend_gc.c:996)
==4313== by 0x88A773: shutdown_executor (zend_execute_API.c:336)
==4313== by 0x8A2B03: zend_deactivate (zend.c:964)
==4313== by 0x815EA4: php_request_shutdown (main.c:1814)
==4313== by 0x963775: do_cli (php_cli.c:1135)
==4313== by 0x963E53: main (php_cli.c:1334)
==4313==
==4313== 56 bytes in 1 blocks are definitely lost in loss record 25 of 27
==4313== at 0x4C29F90: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4313== by 0x871E2E: _emalloc (zend_alloc.c:2211)
==4313== by 0x8A9609: _array_init (zend_API.c:1093)
==4313== by 0x7F3A32: php_http_message_object_get_props (php_http_message.c:954)
==4313== by 0x8E82D6: zend_std_get_gc (zend_object_handlers.c:126)
==4313== by 0x8D5EE2: gc_collect_white (zend_gc.c:731)
==4313== by 0x8D62E4: gc_collect_roots (zend_gc.c:846)
==4313== by 0x8D6880: zend_gc_collect_cycles (zend_gc.c:1007)
==4313== by 0x88A773: shutdown_executor (zend_execute_API.c:336)
==4313== by 0x8A2B03: zend_deactivate (zend.c:964)
==4313== by 0x815EA4: php_request_shutdown (main.c:1814)
==4313== by 0x963775: do_cli (php_cli.c:1135)
==4313== by 0x963E53: main (php_cli.c:1334)
==4313==
==4313== LEAK SUMMARY:
==4313== definitely lost: 182 bytes in 4 blocks
==4313== indirectly lost: 0 bytes in 0 blocks
==4313== possibly lost: 0 bytes in 0 blocks
==4313== still reachable: 1,054 bytes in 23 blocks
==4313== suppressed: 0 bytes in 0 blocks
==4313== Reachable blocks (those to which a pointer was found) are not shown.
==4313== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==4313==
==4313== For counts of detected and suppressed errors, rerun with: -v
==4313== ERROR SUMMARY: 4 errors from 4 contexts (suppressed: 0 from 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment