|Subject:||Named Pipe again|
|Posted by:||Markus (markus.hu…@freenet.de)|
|Date:||9 Mar 2007|
I thought I'd got rid of my pipe problems lately with the help from this forum and some changes of my own, but now I've figured out that it isn't so. The application has a huge problem, it leaks about 4K kernel memory every 2 seconds! After several hours or days, depending on memory size the machine halts.
I've nailed it down now to my pipeserver thread which currently looks like this:
if (PipeHandle = INVALID_HANDLE_VALUE) or
(Overlapped.hEvent = 0) then Exit;
portstr := '1234';
while not Terminated do
case WaitForSingleObject(Overlapped.hEvent, 100) of
WriteFile(PipeHandle, PChar(portstr)^, Length(portstr),
// if this break is present no kernel memory is leaked, but the // thing obvisiously only runs once. I'd like it to run until
// somebody else terminated the thread but without leaking
// memory. => where exactly does this leaking come from?
So my question is, where exactly does this leakeage come from and how to avoid it whithout making the thread a run once thing as it is right now with that break instruction?