I tested in Purify+ - it does not show the leak in setlocale. It always finds a reason to complain, but I get the same report with setlocale in the code and without it.
Hi,
I am making _tsetlocale calls to set the locale information in my application. Memory Leak Analyzer is showing memory leak for the following code:
_tsetlocale(LC_COLLATE, _T(""));
Its showing memory leak in the following function in the file :
"C:\Program Files\Microsoft Visual Studio 9.0\VC\crt\src\wsetloca.c"
wchar_t * __cdecl _wsetlocale (
int _category,
const wchar_t *_wlocale
)
Inside this function its showing leak at the following line:
refcount = (int *)_malloc_crt(size * sizeof(wchar_t) + sizeof(int));
Its showing 58 bytes leak for one call of _tsetlocale.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Looks like: setlocale(LC_ALL, ""); in the end is the fix.
Here you can find more info: http://binglongx.spaces.li
Actually
http://www.tech-archive.ne
says that it does not happen in VS 7.1.
Here is a guy saying that the detection time is wrong: http://groups.google.com/g
free memory happens a bit later.
Here is even a screenshort from the BoundChecker: http://www.codeguru.com/FO
#in
#include <tchar.h>
#include <crtdbg.h>
#include <locale.h>
int _tmain()
{
setlocale(LC_ALL, "");
_CrtDumpMemoryLeaks();
}
This code didn't show the leak.
we don't call LC_ALL as it breaks SQLite3 by replacing the '.' in floats/DATEs with a ',' in some languages.
I am using SQLite3 database.
It is confirmed that in VS2008 this issue is fixed. Not in VS 2005.
Is there any other way to get rid of this memory leak.
One more question related to memory leak:
Some memory leaks come in debug build but not in release build. Does it mean that when we ship our application (release build) then these memory leaks will not come?
Leak is the leak. If you use different source code, different libraries for the debug and release configurations, ..., everything's possible.
But better do not hope that the release version does not have a leak if the debug does.
The release is much smaller then the debug. So the leak can make a trouble later.
Business Accounts
Answer for Membership
by: pgnatyukPosted on 2009-07-15 at 07:02:59ID: 24859445
Here someone reports about the same issue: http://blog.kalmbachnet.de /?postid=4 7
But that was in 2005. Here people say that it's fixed: http://connect.microsoft.c om/VisualS tudio/feed back/ViewF eedback.as px?Feedbac kID=99285
H ere are few examples if you need:
http://msdn.microsoft.com/ en-us/libr ary/x99tb1 1d.aspx
htt p://www.te nouk.com/M oduleG1.ht ml
But looks like you can release the memory? I will try to check it with BoundChecker.