Thread: STL leaking?

  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
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,794
    is your obiect destructed at some point?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    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, 05: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