String::String(float/double) have _locale_t object leak


String::String(float/double) have _locale_t object leak

Tested and reproduced on Window 7 64 Pro Sp1 US.
On Current Juce Trunk.
With Visual Studio 2008 SP1 (project linked with MultiThreaded DLL Runtime library)

In juce_String.cpp
namespace NumberToStringConverters
when JUCE_MSVC is defined the function doubleToString() calls _create_locale without calling requested _free_locale on the returned _locale_t object.

This create a growing leak at each call to String(double) String(float).
The process memory is growing more and more, but Visual Studio did not find any leak at exit.

Calling _free_locale fix this problem.

Thanks to Lori Thantos for its MSDN community additions message pointing that the MSDN sample is leaking too.


Wow, thanks for the heads-up. I guess I just followed the crappy MSDN example, and C-library calls often return pointers that don’t need to be freed, so it didn’t seem unusual to expect it to work like that. Will fix imminently.


Great !

Juce is more homogeneous than C-library.
It’s a pain to read all pitfall about this old API.

I hope your static fix did not interfere with obscure implementation of dll initializing and per thread locale management.

In my case it’s working perfectly.

Thanks for your reactivity on this issue.


Thanks. Should work fine as a static AFAIK, and will actually be faster than it was before.