Sorry for the delayed response.  I ended up creating two stripped down sample 
applications to recreate the issue.

We thought that it was machine related, because I could reproduce the growing 
handle issue with these apps within 5-10 minutes, whereas another 2 developers 
could not.  However, after running the test for 3 days, one of them experienced 
handle growth of 71K!

I've submitted a question on Stack Overflow, but so far crickets as to what 
could cause a problem like this (other than obvious API calls that open 
security-context tokens handles):

Where can I upload the source code for these two apps so you can compile an run 

Note that you may have to run the test for at least a day to begin seeing the 
leaks. I ran both apps on the same machine (HTTP Client + Server).

At this point, we've put months of time into this project and this is a show 
stopper. Perhaps you can identify something I'm doing that's fundamentally 
wrong in the sample code, but I suspect something much more subtle is going on. 
 It was very odd that when I ran the apps in another machine, the extremely 
rapid increase in handles seemed to go away, but still crept up over time.  

In any case, I'm at the point where I'm considering ripping out ICS and 
replacing it with something like Real Thin Client.  I don't want to start from 
scratch, but unless I can determine and fix the cause of this problem, I have 
no choice.

I really hope it's something I'm doing wrong in my code.


-----Original Message-----
From: Angus Robertson - Magenta Systems Ltd [] 
Sent: Wednesday, July 30, 2014 10:57 AM
Subject: Re: [twsocket] Handle Leak

> I'm using the Version 8 'Gold' build of the ICS components with Delphi 
> XE2 and I'm seeing some strange handle leaks.  Note that I'm not using 
> SSL.
> I've run the application for 48 hours, and have confirmed there are 
> absolutely no memory leaks (memory usage is stable), but the working 
> set keeps growing.  After running Process Explorer and logging handle 
> counts  I've managed to narrow down the leak to Access Token handles.

I run several ICS applications for up to a month at time on multiple PCs and 
servers, often only restarting for Windows Updates, and I've not seen any 
handle or memory leaks.  

There is a major handle leak in some releases of Microsoft ADO using 
asynchronous calls to access databases, fixed a couple of years ago, one of my 
applications ending up using 500,000 handles. 

Which specific ICS components are you using, and how many handles are leaked 
per hour?  Or is it per connection or something? 

My understanding is access token handles relate to the security context of a 
process or thread, and ICS essentially does not use threads or create any 


To unsubscribe or change your settings for TWSocket mailing list
please goto
Visit our website at

Reply via email to