Re: ZTS leak
| From: | Zeev Suraski | Date: | Tue, 30 Aug 2005 00:26:04 +0000 |
| Subject: | Re: ZTS leak | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-18541@lists.php.net to get a copy of this message | ||
At 01:13 30/08/2005, Sara Golemon wrote:
In looking into a series of leaks regarding tsrm interpreter contexts with George and Wez, we came across a problem with how EG(zend_constants) is created and destroyed. Specifically it's only destroyed once, from zend_shutdown(). However it's created by executor_globals_ctor(). In non-ZTS this isn't a problem since egctor is only called the one time during startup, however when ZTS is enabled egctor gets called repeatedly (including once for every request startup) and the allocated EG(zend_constants) is leaked over and over again.As far as I can tell it's a bug. By the way, we're not talking about a leak that happens too often - unless you're spawning and killing threads very often (in which case TSRM is very inefficient regardless of anything). The leak would happen per-terminated thread.
Of lesser criticality (but no less important) rsrc_plist is also leaked by this unbalanced positioning.Ditto.
I temporarily plugged the constants leak (90k+ per request) by using the patch below (though it's inefficient for obvious reasons), but rsrc_plist will take a slightly different approach (heading out the door now so no time to think it through).90K+ per request sounds wrong. I guess that you're either measuring right after the server startup, when the threads are not yet initialized - and then every request initiates a new thread; Or you're using a very odd web server that spawns a thread for each incoming request (bad idea!). If it's the former, then that leak is actually not nearly as bad as you thought, if it's the latter... Fixing that leak should be the least of your worries :)
There's also a 200 byte leak in the thread key, but that's once per engine and not a per-request issue so I'm even less concerned about that one. -Sara Index: Zend/zend.c =================================================================== RCS file: /repository/ZendEngine2/zend.c,v retrieving revision 1.308 diff -u -r1.308 zend.cAre you sure it's not leaking the global constants table with the zend_shutdown_constants() removed from zend_shutdown()? Zeev--- Zend/zend.c 3 Aug 2005 13:30:45 -0000 1.308+++ Zend/zend.c 29 Aug 2005 21:40:13 -0000 @@ -486,6 +486,7 @@ static void executor_globals_dtor(zend_executor_globals *executor_globals TSRMLS_DC) {zend_ini_shutdown(TSRMLS_C); + zend_shutdown_constants(TSRMLS_C);} @@ -706,7 +707,6 @@zend_shutdown_extensions(TSRMLS_C); free(zend_version_info);- zend_shutdown_constants(TSRMLS_C); free(GLOBAL_FUNCTION_TABLE); free(GLOBAL_CLASS_TABLE);#ifdef ZTS