The Zend memory manager, backported to PHP 3.0

From: Date: Fri, 05 Feb 1999 15:15:09 +0000
Subject: The Zend memory manager, backported to PHP 3.0
Groups: php.dev 
Request: Send a blank email to php-dev+get-3924@lists.php.net to get a copy of this message
Hi, I've just committed a backported version of the Zend improved memory manager into PHP 3.0. The new memory manager offers improved debugging support by making use of magic numbers. The debugging memory manager is enabled is PHP is configured with --enable-debug (i.e., if DEBUG is true). In most cases, it would be enough to simply compile PHP in debug mode to track down most memory errors. However, there are two new API functions available for you during the development/debug period. One is mem_block_check(p, silent), and the other is full_mem_check(silent). mem_block_check() tests the block for valid magic numbers, and reports back about the status of the block. If silent is 1, no output is emitted if the block's magic numbers are intact. mem_block_check() is run implicitly every time a memory block is efree()'d (which is why you normally don't have to add any explicit calls, usually the memory manager will just find the problems for you). full_mem_check() runs mem_block_check() on all of the active memory blocks in the memory manager. The silent argument controls whether or not mem_block_check is instructed to be silent or not. The memory manager protects from buffer underflows/overruns (i.e., smashing of the beginning of the block), and buffer overflows (i.e. writing beyond the end of the block). The end of the block is checked only if the beginning of the block is valid (since in order to check the end of the block, the memory manager must know the size of the block, which is stored at the block's header). Thus, if your block has been overrun, you'd see that the block end's status is 'Unknown'. In case of buffer overflows, the memory manager will report how many bytes have been overflown - upto 3 bytes. 4 or more bytes of overflow will be reported as '4 or more bytes'. If you're investigating crashes, you'd find that memory manager very useful. Mail me if you have any questions about it. Zeev -- ----------------------------------------------------- Zeev Suraski <zeev@zend.com> For a PGP public key, finger bourbon@netvision.net.il -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#3924) next »