When an extension is loaded from a script rather than the ini file, the resources are being destroyed incorrectly. When I change zend_list and zend_hash to the following, the resources are now destroyed in the same order as they are when the extension is loaded from the ini file and no more memory issues (tested under windows).
It seems zend_clean_module_rsrc_dtors should be changed to something along the lines of: zend_list.c void zend_clean_module_rsrc_dtors(int module_number TSRMLS_DC) { zend_hash_apply_reverse_with_argument(&list_destructors, (apply_func_arg_t) zend_clean_module_rsrc_dtors_cb, (void *) &module_number TSRMLS_CC); } zend_hash.c ZEND_API void zend_hash_apply_reverse_with_argument(HashTable *ht, apply_func_arg_t apply_func, void *argument TSRMLS_DC) { Bucket *p; IS_CONSISTENT(ht); HASH_PROTECT_RECURSION(ht); p = ht->pListTail; while (p != NULL) { if (apply_func(p->pData, argument TSRMLS_CC)) { p = zend_hash_apply_deleter(ht, p); } else { p = ht->pListTail; } } HASH_UNPROTECT_RECURSION(ht); } does this seem to be correct? Basically the only change is that it traverses the hash table in reverse. didnt make a diff as not sure wether this is correct logic or if there is a functions already there which would do the same aszend_hash_apply_reverse_with_argument. Thanks, Rob -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php