I have been looking at the IIS isapi issues and came up with the following patch: http://www.ctindustries.net/patches/zts-php5.diff.txt
The changes are not just local to the isapi as it seems that all sapis running in ZTS mode would leak. The patch includes changes to cgi, isapi and apache2 sapis (cli tested fine without change). They have only been tested under windows however. Before I spent more time moving this stuff over to linux to test I wanted to know if this is at least in the right direction. Could someone take a look at this patch as it touches on some zend changes and core php changes, but only under ZTS. One area which I wasn't sure of was the changes in basic_functions.c and url_scanner_ex.c. The code works fine, but I'm not sure if there is a more appropriate way to do this. With the windows isapi, other than a few leaks from the language scanner depending upon the script run, requests no longer leak and local thread memory is cleaned up correctly. Testing the included sapis, upon server shutdown, there is only under 500 bytes leaking (which is substantially less than before). I also can make available a patch for PHP 4, as the changes are a little bit different, but wasn't sure if a) these changes are valid and b) should these changes be made to the 4_3 branch since it is stable right now. Thanks, Rob