Re: string memory leak?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Carl Daniel [VC++ MVP] wrote:
navels wrote:
I've been battling a memory leak in a C++ console app for some time.
I
have finally tracked down the source by using the Microsoft tool umdh
for dumping the heap. I seem to be unable to reproduce the problem in
a small code snippet. Hopefully I can post enough information here to
make sense to folks.

BTW, I am compiling with Visual C++ 6.0.

Have you applied the STL patches available from

https://www.dinkumware.com/vc_fixes.html

??

If not, you should. Pay particular attention to the fixes to <xstring>

-cd

Ahhhh, thanks. I needed to make std::string thread-safe. There is
more information about this problem here:

http://support.microsoft.com/default.aspx?scid=kb;en-us;813810

I still have one more leak that has something to do with std::string.
I am surprised that the dinkumware fixes did not address this leak as
well. Here is the output from umdh for that one:

000000B0 bytes in 0x1 allocations (@ 0x00000050 + 0x00000018) by:
BackTrace00646
ntdll!RtlDebugAllocateHeap+000000E1
ntdll!RtlAllocateHeapSlowly+00000044
ntdll!RtlAllocateHeap+00000E64
server!_heap_alloc_base+0000013C (malloc.c, 200)
server!_heap_alloc_dbg+000001A2 (dbgheap.c, 378)
server!_nh_malloc_dbg+00000049 (dbgheap.c, 248)
server!_nh_malloc+00000016 (dbgheap.c, 197)
server!operator new+0000000F (new.cpp, 24)
server!std::_Allocate+0000002E (c:\program files\microsoft
visual studio\vc98\include\xmemory, 30)
server!std::allocator<char>::allocate+00000028 (c:\program
files\microsoft visual studio\vc98\include\xmemory, 59)

server!std::basic_string<char,std::char_traits<char>,std::allocator<char>
::_Copy+00000069 (c:\program files\microsoft visual studio\vc98\include\xstring, 540)

server!std::basic_string<char,std::char_traits<char>,std::allocator<char>
::_Grow+00000128 (c:\program files\microsoft visual studio\vc98\include\xstring, 586)

server!std::basic_string<char,std::char_traits<char>,std::allocator<char>
::assign+0000012C (c:\program files\microsoft visual studio\vc98\include\xstring, 142)

server!std::basic_string<char,std::char_traits<char>,std::allocator<char>
::basic_string<char,std::char_traits<char>,std::allocator<char> >+00000045 (c:\program files\microsoft visual studio\vc98\include\xstring, 58)
server!ClientParam::ClientParam+0000005B (server.cxx, 59)
server!server+000004E6 (server.cxx, 200)
server!main+00000153 (servermain.cpp, 47)
server!mainCRTStartup+000000FC (crt0.c, 206)
kernel32!BaseProcessStart+00000023

I am upgrading to Visual Studio 2005 at the moment and will report back
if that fixes things.

Thanks again,
Lee

.



Relevant Pages

  • Re: string memory leak?
    ... have finally tracked down the source by using the Microsoft tool umdh ... a small code snippet. ... I still have one more leak that has something to do with std::string. ... I am surprised that the dinkumware fixes did not address this leak as ...
    (microsoft.public.vc.stl)
  • Re: string memory leak?
    ... have finally tracked down the source by using the Microsoft tool umdh ... for dumping the heap. ... I seem to be unable to reproduce the problem in ...
    (microsoft.public.vc.stl)
  • Re: Possible memory leak in net/wireless/scan.c
    ... I'll try this later today to see if it fixes the leak. ... I can now confirm that it fixes the memory leak. ... More majordomo info at http://vger.kernel.org/majordomo-info.html ...
    (Linux-Kernel)
  • Re: Possible memory leak in net/wireless/scan.c
    ... I'll try this later today to see if it fixes the leak. ... I can now confirm that it fixes the memory leak. ...
    (Linux-Kernel)
  • Re: Possible memory leak in net/wireless/scan.c
    ... I'll try this later today to see if it fixes the leak. ... I have already sent that exact patch. ...
    (Linux-Kernel)