Article View: borland.public.cppbuilder.internet.socket
Article #696Re: TIdTCPServer Memory Leak
From: 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
Technical Details
Message-ID:
<4734d3d7@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<47336f10$1@newsgroups.borland.com> <473379be$1@newsgroups.borland.com> <47349c3a$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,8e59db61125c85b X-Google-Attributes: gid11508e,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <47336f10$1@newsgroups.borland.com> <473379be$1@newsgroups.borland.com> <47349c3a$1@newsgroups.borland.com> Subject: Re: TIdTCPServer Memory Leak Date: Fri, 9 Nov 2007 13:33:30 -0800 Lines: 37 Organization: Lebeau Software X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 NNTP-Posting-Host: 207.178.157.90 Message-ID: <4734d3d7@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1194644439 207.178.157.90 (9 Nov 2007 13:40:39 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail X-Original-Bytes: 2062