locked
Memory Leak in setlocale RRS feed

  • Question

  • 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.

    Thanks in advance
    Harish
    Wednesday, August 12, 2009 4:50 AM

Answers

  • That's normal.  These CRT allocations don't get cleaned-up until the CRT shuts down.  Kinda hard to report leaks when the CRT is no longer available.  When you see leaks from internal CRT code, you can safely assume it is not a real leak.

    Hans Passant.
    • Marked as answer by nobugz Saturday, August 22, 2009 10:07 PM
    Wednesday, August 12, 2009 12:09 PM

All replies

  • That's normal.  These CRT allocations don't get cleaned-up until the CRT shuts down.  Kinda hard to report leaks when the CRT is no longer available.  When you see leaks from internal CRT code, you can safely assume it is not a real leak.

    Hans Passant.
    • Marked as answer by nobugz Saturday, August 22, 2009 10:07 PM
    Wednesday, August 12, 2009 12:09 PM

  • When CRT shuts down. When this memory will be free.


    I used GetProcessMemoryInfo API for measuring the memory leak. I found that due to this SetLocale 19501 bytes are leaking in my application.
    Dev Partner is also showing this leak.



    Thursday, August 13, 2009 7:26 AM