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: Brian Mckinnon
Subject: Re: Operators 'new', 'delete' and thread safety.
Date: 18 Apr 2007 07:17:14 -0700
User-agent: G2/1.0

> >> Is it safe to use operators 'new' and 'delete' in a multithreaded
> >> programs, that is: are those operators thread-safe in a current
> >> implementation of g++?

I'm actually having a problem with what appears to a new/delete thread
safety issue, and this is actually the second time it has happened to
me.  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.  The original problem
happened when I was actually calling new and delete on a bunch of
objects, while my current problem occurs with a std::vector of
std::vector's.

This seems crazy to me though.  The only thing I can think is that new
and delete are not thread safe, but I know that can't be true.  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.

I'm not positive about my compiler version, but it is at least 4.1.2.



reply via email to

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