Hi guys,
 
I'm new to this list an am also not really sure if it's the right one for my problem. I'll ask anyway but feel free to direct me elsewhere if I missed the list. I apologise for the long post in advance, I'm trying to explain the problem the best I can:
 
Background:
I have written a simple HTTP server in Borland Delphi using Nevrona's Indy 10.x socket components. From my server I am calling PHP 5.0.5 through it's php5isapi.dll. As far as I know (MSDN documentation) I implemented all the functions required for ISAPI plugin to work. PHP programs I wrote use mbstring and soap extensions. Default and internal string encoding is UTF-8.
 
Now for the problem:
PHP seems to loose some 12 KB of RAM for each call I make to it. If that call originates from a new thread each time, additional 100KB of RAM is taken. So my current solution just makes sure the same worker threads always call PHP.I have determined this by running a PHP script through my server some 1000 times and comparing initial / ending mem usage of my server process in TaskManager. Those 12KB are variable and range between 2.5 and 22KB depending on my computer's mood. I really can't put it differently since I really don't know what governs this variability. The code ran is always the same and scripts requested too.
 
I compared these figures with PHP running through Apache 2.x and it seems the Apache config doesn't loose RAM like this. Of course, Apache version uses a different interface. I didn't test this on IIS / PWS. I'm pretty sure it's PHP that's loosing RAM since I only use Delphi's memory routines for allocation / deallocation and Delphi memory manager does not detect any leaks.
 
My original implementation was through php5ts.dll (Serhiy Perevoznyk's classes), but that one lost .5 MB per call initially and some 200KB after I debugged as much as I knew to. Since I found that interface more complex I decided to write my own ISAPI "server" in the hope of solving this problem. Providing it's source for you to test is no problem.
I'm really sorry, but I couldn't understand the php source code well enough to be able to pinpoint the problem through reading it. I don't consider myself to be exactly C/C++ noob, but that code is just too advanced for me, not to mention huge.
 
I have not detected any unusual (not explained) calls to either of these functions:
GetServerVariable
WriteClient
ReadClient
ServerSupportFunction
 
My only action for calling PHP is setting up the ECB and then calling the httpfunc of the lib.
 
Questions:
Has anybody noticed this problem with ISAPI interface?
Is there a way to get rid of this problem?
On the side note: I'm not getting any logging information either in the form of filled out ECB.lpszLogData nor through HSE_APPEND_LOG_PARAMETER command of ServerSupportFunction. If I set PHP to log into a file, it will do so, but I'd really like to log through my server. I'd like some pointers on that too if possible.
 
Thanks for any help,
Jure Erznoznik
Application developer
Jantar d.o.o.
 

Reply via email to