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.

Of lesser criticality (but no less important) rsrc_plist is also leaked by
this unbalanced positioning.

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).

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.c
--- 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

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to