Memory leak after calling exit() when Zend MM is turned off?
| From: | Pascal Mathis | Date: | Wed, 16 Jan 2013 19:53:51 +0000 |
| Subject: | Memory leak after calling exit() when Zend MM is turned off? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-64997@lists.php.net to get a copy of this message | ||
Hi internals!
I am currently developing a Zend extension. Because the Zend MM leak reports are not really useful sometimes, I switched the memory manager off with the environment variable USE_ZEND_ALLOC=0, so that I can use valgrind.
Right now I have found some kind of memory leak. You can use every script which has an exit()-call to reproduce this leak. For example:
<?php exit("Memory leak example.\n"); ?>
If you run this PHP script with valgrind, it will report some ugly memory leak:
valgrind version: valgrind-3.6.0.SVN-Debian
PHP Version: 5.4.10 (debug)
Configure options: --disable-all --disable-cgi --enable-debug
---
Command: export USE_ZEND_ALLOC=0 && valgrind --leak-check=full php-5.4.10-debug test.php
---
Report:
==5693== HEAP SUMMARY:
==5693== in use at exit: 420 bytes in 4 blocks ==5693== total heap usage: 8,355 allocs, 8,351 frees, 2,503,705 bytes allocated==5693== ==5693== 420 (240 direct, 180 indirect) bytes in 1 blocks are definitely lost in loss record 4 of
==5693== at 0x4C244E8: malloc (vg_replace_malloc.c:236) ==5693== by 0x5E08C4: _emalloc (zend_alloc.c:2423) ==5693== by 0x5C11C3: compile_file (zend_language_scanner.l:551) ==5693== by 0x617311: zend_execute_scripts (zend.c:1301) ==5693== by 0x58A22F: php_execute_script (main.c:2482) ==5693== by 0x768967: do_cli (php_cli.c:988) ==5693== by 0x76987C: main (php_cli.c:1364)==5693== ==5693== LEAK SUMMARY:
==5693== definitely lost: 240 bytes in 1 blocks ==5693== indirectly lost: 180 bytes in 3 blocks ==5693== possibly lost: 0 bytes in 0 blocks ==5693== still reachable: 0 bytes in 0 blocks ==5693== suppressed: 0 bytes in 0 blocksWhen the Zend memory manager is turned on, everything is fine. Is this behavior intended? Thanks in advance, Pascal