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

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

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<char>
f:\rtm\vctools\crt_bld\self_x86\crt\src\xmemory (152): std::allocator<char>::allocate
f:\rtm\vctools\crt_bld\self_x86\crt\src\xstring (1982): std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Copy
f:\rtm\vctools\crt_bld\self_x86\crt\src\xstring (2012): std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Grow
f:\rtm\vctools\crt_bld\self_x86\crt\src\xstring (1032): std::basic_string<char,std::char_traits<char>,std::allocator<char> >::assign
f:\rtm\vctools\crt_bld\self_x86\crt\src\xstring (1043): std::basic_string<char,std::char_traits<char>,std::allocator<char> >::assign
f:\rtm\vctools\crt_bld\self_x86\crt\src\xstring (893): std::basic_string<char,std::char_traits<char>,std::allocator<char> >::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<char>
f:\rtm\vctools\crt_bld\self_x86\crt\src\xmemory (152): std::allocator<char>::allocate
f:\rtm\vctools\crt_bld\self_x86\crt\src\xstring (1982): std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Copy
f:\rtm\vctools\crt_bld\self_x86\crt\src\xstring (2012): std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Grow
f:\rtm\vctools\crt_bld\self_x86\crt\src\xstring (1019): std::basic_string<char,std::char_traits<char>,std::allocator<char> >::assign
f:\rtm\vctools\crt_bld\self_x86\crt\src\xstring (1006): std::basic_string<char,std::char_traits<char>,std::allocator<char> >::assign
f:\rtm\vctools\crt_bld\self_x86\crt\src\xstring (888): std::basic_string<char,std::char_traits<char>,std::allocator<char> >::operator=

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.