STL leaking?

This is a discussion on STL leaking? within the C++ Programming forums, part of the General Programming Boards category; Hi, I've been trying to find mem leaks with Visual Leak Detector. And a few detected on the STL like ...

  1. #1
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476

    STL leaking?

    Hi, I've been trying to find mem leaks with Visual Leak Detector. And a few detected on the STL like the example below:

    The callstack is:
    c:\program files\microsoft visual studio 8\vc\include\xmemory (44): std::_Allocate<char>
    c:\program files\microsoft visual studio 8\vc\include\xmemory (146): std::allocator<char>::allocate
    c:\program files\microsoft visual studio 8\vc\include\xstring (1972): std::basic_string<char,std::char_traits<char>,std: :allocator<char> >::_Copy
    c:\program files\microsoft visual studio 8\vc\include\xstring (2002): std::basic_string<char,std::char_traits<char>,std: :allocator<char> >::_Grow
    c:\program files\microsoft visual studio 8\vc\include\xstring (1022): std::basic_string<char,std::char_traits<char>,std: :allocator<char> >::assign
    c:\program files\microsoft visual studio 8\vc\include\xstring (1033): std::basic_string<char,std::char_traits<char>,std: :allocator<char> >::assign
    c:\program files\microsoft visual studio 8\vc\include\xstring (634): std::basic_string<char,std::char_traits<char>,std: :allocator<char> >::basic_string<char,std::char_traits<char>,std::a llocator<char> >
    My leaking code:
    Code:
    class DecoFrame {
    
    
    	private:
    
    
    		std::string m_strOverlayFilename;
    		std::string m_strThumbnailFilename;
    ...
    };
    
    DecoFrame::DecoFrame(
    	const char* szOverlayFilename,
    	const char* szThumbnailFilename
    ) :
    	m_strOverlayFilename( szOverlayFilename ), <-- this one is leaking
    	m_strThumbnailFilename( szThumbnailFilename ), <-- also this one 
    	m_pTextureOverlay( NULL ),
    	m_pTextureThumbnail( NULL )
    {
    }
    So you see, it was only some instances of std::string but VLD reported them leaking. Is it really leaking? FYI I'm using then default STL from VS 2005 so if it's leaking, does that mean I should use stlport instead?
    ERROR: Brain not found. Please insert a new brain!

    “Do nothing which is of no use.” - Miyamoto Musashi.

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,473
    is your obiect destructed at some point?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,295
    Member variables that allocate memory will appear as a leak if the instance of the class itself is leaked.
    Look for instances of DecoFrame that are leaked. Fix those and you'll fix the problem.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  4. #4
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476
    OIC. Got it. I'll check for any instance of DecoFrame deletion. Thanks.
    ERROR: Brain not found. Please insert a new brain!

    “Do nothing which is of no use.” - Miyamoto Musashi.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C Formatting Using STL
    By ChadJohnson in forum C++ Programming
    Replies: 4
    Last Post: 11-18-2004, 04:52 PM
  2. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  3. STL or no STL
    By codec in forum C++ Programming
    Replies: 7
    Last Post: 04-12-2004, 02:36 PM
  4. Prime Number Generator... Help !?!!
    By Halo in forum C++ Programming
    Replies: 9
    Last Post: 10-20-2003, 07:26 PM
  5. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21