Thread View: borland.public.cppbuilder.internet.socket
4 messages
4 total messages
Started by Mark Roberts
Thu, 08 Nov 2007 20:18
TIdTCPServer Memory Leak
Author: Mark Roberts
Date: Thu, 08 Nov 2007 20:18
Date: Thu, 08 Nov 2007 20:18
8 lines
1169 bytes
1169 bytes
I'm using Indy's TIdTCPServer component in C++ Builder 6.0 and getting a memory leak. My client is connecting and disconnecting every 5 seconds. Is there known issues with TIdTCPServer leaking memory? How do I go about resolving this problem? Thanks for your help, Mark Roberts
Re: TIdTCPServer Memory Leak
Author: Remy Lebeau (TeamB)
Date: Thu, 08 Nov 2007 21:03
Date: Thu, 08 Nov 2007 21:03
12 lines
1324 bytes
1324 bytes
"Mark Roberts" <markr@piracle.com> wrote in message news:47336f10$1@newsgroups.borland.com... > I'm using Indy's TIdTCPServer component in C++ Builder 6.0 > and getting a memory leak. You need to be more specific. What is leaking exactly? How do you know that it is a leak to begin with? Gambit
Re: TIdTCPServer Memory Leak
Author: Mark Roberts
Date: Fri, 09 Nov 2007 17:43
Date: Fri, 09 Nov 2007 17:43
40 lines
2326 bytes
2326 bytes
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message news:473379be$1@newsgroups.borland.com... > > "Mark Roberts" <markr@piracle.com> wrote in message > news:47336f10$1@newsgroups.borland.com... > >> I'm using Indy's TIdTCPServer component in C++ Builder 6.0 >> and getting a memory leak. > > You need to be more specific. What is leaking exactly? How do you know > that it is a leak to begin with? > > > Gambit > My app is running as a service. It uses a TIdTCPServer component to communicate with clients. As I watch the Processes screen of the Task Manager I see the process continually growing as the clients connect and disconnect. I'm calling AThread->Connection->Disconnect in the OnExcute function and AThread->StopMode = smTerminate; AThread->Stop(); TCPServer->ThreadMgr->ReleaseThread(AThread); TCPServer->ThreadMgr->TerminateThreads(TCPServer->ThreadMgr->ActiveThreads); in the OnDisconnect function. Even when I comment out all code in the OnExecute routine other than the ATread->Connection->Disconnect the service continues to grow. Googling TIdTCPServer seems to indicate that this component leaks memory but I can't find a solution. Any insights would be greatly appreciated. Mark
Re: TIdTCPServer Memory Leak
Author: Remy Lebeau (TeamB)
Date: Fri, 09 Nov 2007 21:33
Date: Fri, 09 Nov 2007 21:33
35 lines
2202 bytes
2202 bytes
"Mark Roberts" <markr@piracle.com> wrote in message news:47349c3a$1@newsgroups.borland.com... > As I watch the Processes screen of the Task Manager I see > the process continually growing as the clients connect and > disconnect. Task Manager is a very poor way to measure leaking. Borland/CodeGear's memory manager does not release freed memory back to the OS right away. It is cached for later re-use. Task Manager has no way of knowing that. All it shows is how much memory is allocated to the process, but not how the process is actually using the memory. > I'm calling AThread->Connection->Disconnect in the > OnExcute function That is fine. > AThread->StopMode = smTerminate; > > AThread->Stop(); > > TCPServer->ThreadMgr->ReleaseThread(AThread); > > TCPServer->ThreadMgr->TerminateThreads(TCPServer->ThreadMgr->ActiveThreads); > > in the OnDisconnect function. Do not do ANY of that! Especially NOT in the OnDisconnect event! The thread is still active inside that event. It can't be released yet. Let TIdTCPServer do all of the thread management for you. Gambit
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads