 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Vern Six Guest
|
Posted: Wed Feb 25, 2004 8:33 am Post subject: TIdPop3Server question about AThread.Data |
|
|
I have created an object (TVsUserData) that I istantiate in the
TIdPop3Server.OnConnect event handler. I assign this object to the
ATHREAD.DATA property per the Indy docs.
Given: This object contains a simple TStringList as one of its
properties.
In the various Event handlers for TIdPop3Server, I add strings to
that TStringList to create a log of sorts. ie: In the OnRETR, I add a
string that tells me what message the user is RETRieving, etc.
Then in the TIdPop3Server.OnDisconnect event handler, I SaveToFile()
the stringlist so I can look at it later. I then CLEAR the
TStringlist and then FREE it.
This produces a memory leak... a huge memory leak. I'm baffled as to
where to look next.
If I don't use the TStringList, the rest of my object works fine in
the TIdPop3Server event handlers. But the second I add the
TStringList code... it sucks memory faster than I can keep up with.
I've even tried using a "Thread Safe" TStringList and it makes no
difference.
Anyone have any ideas?
Thanks in advance!
Vern
|
|
| Back to top |
|
 |
Martin James Guest
|
Posted: Wed Feb 25, 2004 10:14 am Post subject: Re: TIdPop3Server question about AThread.Data |
|
|
| Quote: | Then in the TIdPop3Server.OnDisconnect event handler, I SaveToFile()
the stringlist so I can look at it later. I then CLEAR the
TStringlist and then FREE it.
This produces a memory leak... a huge memory leak. I'm baffled as to
where to look next.
|
AFAIK, the data object is auto-freed by Indy when a client disconnects. If
you are explicitly freeing it as well, there may be a problem. Still, if
this is the case & your context-object is being freed twice, I would expect
an AV rather than a leak.
Rgds,
Martin
|
|
| Back to top |
|
 |
Vern Six Guest
|
Posted: Wed Feb 25, 2004 6:20 pm Post subject: Re: TIdPop3Server question about AThread.Data |
|
|
Precisely my thoughts. I've tried it both ways actually. It's really
wierd indeed. It only happens when I use a TStringList. If I use a
string or any other data type... no problems.
For now I'm just using a string and it works fine. But it baffles me
why I can't use a TStringList or TIdThreadSafeStringList
On Wed, 25 Feb 2004 10:14:45 -0000, "Martin James"
<mjames_falcon (AT) dial (DOT) pipex.com> wrote:
| Quote: |
Then in the TIdPop3Server.OnDisconnect event handler, I SaveToFile()
the stringlist so I can look at it later. I then CLEAR the
TStringlist and then FREE it.
This produces a memory leak... a huge memory leak. I'm baffled as to
where to look next.
AFAIK, the data object is auto-freed by Indy when a client disconnects. If
you are explicitly freeing it as well, there may be a problem. Still, if
this is the case & your context-object is being freed twice, I would expect
an AV rather than a leak.
Rgds,
Martin
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Feb 25, 2004 9:18 pm Post subject: Re: TIdPop3Server question about AThread.Data |
|
|
"Vern Six" <vsix (AT) vernsix (DOT) com> wrote
| Quote: | In the various Event handlers for TIdPop3Server, I add strings to
that TStringList to create a log of sorts.
|
Why not just attach a TIdLog... component to the connection and let it
handle all of the logging for you?
| Quote: | This produces a memory leak...
|
It shouldn't be. If it is, then the leak is in your own code.
| Quote: | If I don't use the TStringList, the rest of my object works fine in
the TIdPop3Server event handlers. But the second I add the
TStringList code... it sucks memory faster than I can keep up with.
|
That suggests that you are not freeing the TStringList to begin with.
Gambit
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Feb 25, 2004 9:19 pm Post subject: Re: TIdPop3Server question about AThread.Data |
|
|
"Vern Six" <vsix (AT) vernsix (DOT) com> wrote
| Quote: | It only happens when I use a TStringList. If I use a
string or any other data type... no problems.
|
What does your actual TVsUserData type look like? It sounds like you did
not give it a destructor to free the TStringList.
Gambit
|
|
| Back to top |
|
 |
Martin James Guest
|
Posted: Wed Feb 25, 2004 10:14 pm Post subject: Re: TIdPop3Server question about AThread.Data |
|
|
| Quote: |
What does your actual TVsUserData type look like? It sounds like you did
not give it a destructor to free the TStringList.
|
Perhaps an 'override' is missing somewhere. I've ocasionally done this &
the wrong destructor gets called.
Rgds,
Martin
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|