Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with threads when terminated

Status
Not open for further replies.

dadi

Programmer
May 26, 2003
3
FR

why i have a problem when my thread is terminated
i create an instance of a thread object and start it
with resume methode.
( access violation ...)

i freed all objects allocatec by this thread when is finished .
 
Can you give us more information about what the thread does?

Perhaps it's just a standard access violation, you are freeing something twice or you are freeing a component which has an owner.

It is helpful to comment things out and see if the problem still exists to narrow down where the access violation is occurring.

TealWren
 
Hi there. I seem to be having a similar problem concerning threads and freeing objects. I narrowed down the problem by commenting out code, and it seems to be occuring when I try to free a TClientDataSet I create in the thread's constructor.

I tried creating the TClientDataSet both with owner=nil and owner=application but the problem persists either way.

The strange thing is that the access violation doesn't happen in every instance of the thread which I create and free, but only starts happening when I reach a certain thread count (usually when i exceed 8 threads).

When I remove the line where I try to free the TClientDataSet, the access violation disappears, but I'd really like to free the TClientDataSet in order to avoid taking up memory and perhaps creating memory leaks.

I'd really appreciate any insight and suggestions you may have as to why this is happening and what I can do to solve this problem.

Thanks,

Barak
 
I've never used a TClientDataset in a thread, but maybe it would help if you set the variable to nil after you free it, so no access violations will happen even if it might try to free multiple times.

Good luck. TealWren
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top