27 Dec
2007
27 Dec
'07
12:44 a.m.
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/LocaleFrame... Search for Memory Management to get to the related details. Jeff