954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

HELP Plz:Memory Leak in std::string

hi,
whenever std::string is assigned to another std::string its giving me a memory leak,why is it so....generally std::string's destructor takes care of freeing it.......can anybody help me wht to do to avoid this type of memory leak...???

risa
Light Poster
31 posts since Jul 2007
Reputation Points: 10
Solved Threads: 1
 

It might prove helpful if you post the code showing how you actually are using strings ...

mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
 

1)#define KP_PRODUCTTYPE _T("KeyPoint")
string ProductType = KP_PRODUCTTYPE;

Memory leak report:
---------- Block 3169 at 0x01DC4460: 16 bytes ----------
Call Stack:
f:\rtm\vctools\crt_bld\self_x86\crt\src\xmemory (44): std::_Allocate
f:\rtm\vctools\crt_bld\self_x86\crt\src\xmemory (152): std::allocator::allocate
f:\rtm\vctools\crt_bld\self_x86\crt\src\xstring (1982): std::basic_string,std::allocator >::_Copy
f:\rtm\vctools\crt_bld\self_x86\crt\src\xstring (2012): std::basic_string,std::allocator >::_Grow
f:\rtm\vctools\crt_bld\self_x86\crt\src\xstring (1032): std::basic_string,std::allocator >::assign
f:\rtm\vctools\crt_bld\self_x86\crt\src\xstring (1043): std::basic_string,std::allocator >::assign
f:\rtm\vctools\crt_bld\self_x86\crt\src\xstring (893): std::basic_string,std::allocator >::operator=

also during...
2) IXMLDOMNode* pResultNode;
string AuthInfo = nXmlUtils::ReadString(pResultNode,"AuthenticationInformation");
here "AuthenticationInformation" is a tag from a xml file.

Memory leak report:

---------- Block 3158 at 0x01DC41D0: 16 bytes ----------
Call Stack:
f:\rtm\vctools\crt_bld\self_x86\crt\src\xmemory (44): std::_Allocate
f:\rtm\vctools\crt_bld\self_x86\crt\src\xmemory (152): std::allocator::allocate
f:\rtm\vctools\crt_bld\self_x86\crt\src\xstring (1982): std::basic_string,std::allocator >::_Copy
f:\rtm\vctools\crt_bld\self_x86\crt\src\xstring (2012): std::basic_string,std::allocator >::_Grow
f:\rtm\vctools\crt_bld\self_x86\crt\src\xstring (1019): std::basic_string,std::allocator >::assign
f:\rtm\vctools\crt_bld\self_x86\crt\src\xstring (1006): std::basic_string,std::allocator >::assign
f:\rtm\vctools\crt_bld\self_x86\crt\src\xstring (888): std::basic_string,std::allocator >::operator=

risa
Light Poster
31 posts since Jul 2007
Reputation Points: 10
Solved Threads: 1
 

Supposing that ProductType is a global scope variable, that might be a bogus memory leak report.

mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You