Boost logo

Boost Users :

From: Jeff Garland (jeff_at_[hidden])
Date: 2007-12-26 19:44:59


Richard wrote:
>
> I am always amazed when people superfluously use new. I am willing to
> bet that superfluous use of new is responsible for quite a number of
> C++ memory leaks and heap thrashing. Try:

The new is NOT superfluous. The constructor of std::locale takes a pointer to
a reference counted facet -- effectively taking ownership of the memory. It
will attempt to delete the memory associated with the facet when it goes out
of scope....likely corrupting the stack if written as you suggest.

Here's the best online reference that discusses this topic.

http://www.angelikalanger.com/Articles/C++Report/LocaleFramework/LocaleFramework.html

Search for Memory Management to get to the related details.

Jeff


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net