help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Operators 'new', 'delete' and thread safety.


From: Bernd Strieder
Subject: Re: Operators 'new', 'delete' and thread safety.
Date: Wed, 18 Apr 2007 16:34:48 +0200
User-agent: KNode/0.10.4

Hello,

Brian Mckinnon wrote:

>       The last time it happened to me I did a pretty heavy analysis on
> the problem, and I saw that memory addresses which had been freed by
> one thread were being used by another.  I really wish I kept that
> output file.  The only way I could fix the problem was to use a thread
> safe factory to create and free the memory.

It's not a matter of thread safety to ensure that one thread does not
delete objects used in other threads. The very same problem of creating
dangling pointers or references exists in single-threaded environments.
It would be interesting to know, what your "thread-safe factory" really
does. My bet is, it does more than just arbitrarily serializing
creating and deleting objects, which is what would be expected from the
name.

> Is there a way to override the new and delete functions, or enable 
> some form of malloc debugging so I can at least try and identify the
> issue.

If you are on a supported platform, try valgrind. Compile with debug
infos.

Bernd Strieder





reply via email to

[Prev in Thread] Current Thread [Next in Thread]