LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-27-2009, 04:41 AM   #1
kbarani
Member
 
Registered: Dec 2008
Posts: 41

Rep: Reputation: 15
Where c++ STL sting have memory leak or Not ?


Hi all,
In my c++ application (Linux Fedora Core2) i am using the STL string , for memory leak check i used the valgrind , i set the environment variable as follows export GLIBCPP_FORCE_NEW=1 (or) GLIBCXX_FORCE_NEW=1 , the valgrind report showing memory leak in the STL string, Please tell me whether STL string have memory leak or not ?


Part of Valgrind leak summery:
-------------------------------

==3926== 187 bytes in 11 blocks are possibly lost in loss record 221 of 245
==3926== at 0x47BFE0F: operator new(unsigned int) (vg_replace_malloc.c:214)
==3926== by 0x1806F8: std::__default_alloc_template<true, 0>::allocate(unsigned int) (in /usr/lib/libstdc++.so.5.0.5)
==3926== by 0x1860F7: std::string::_Rep::_S_create(unsigned int, std::allocator<char> const&) (in /usr/lib/libstdc++.so.5.0.5)
==3926== by 0x1861CD: std::string::_Rep::_M_clone(std::allocator<char> const&, unsigned int) (in /usr/lib/libstdc++.so.5.0.5)
==3926== by 0x183DEC: std::string::reserve(unsigned int) (in /usr/lib/libstdc++.so.5.0.5)
==3926== by 0x1842F1: std::string::append(char const*, unsigned int) (in /usr/lib/libstdc++.so.5.0.5)
==3926== by 0x184004: std::string::append(char const*) (in /usr/lib/libstdc++.so.5.0.5)
==3926== by 0x8059335: std::basic_string<char, std::char_traits<char>, std::allocator<char> > std:perator+<char, std::char_traits<char>, std::allocator<char> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*) (basic_string.h:890)
==3926== by 0x805913D: NodeWatch::NodeWatch(Watch*, std::string, Threshold**, std::string) (NodeWatch.cpp:6)
==3926== by 0x8056512: PerformanceMonitor::AddWatches(xercesc_3_0:OMNode*) (PerformanceMonitor.cpp:224)
==3926== by 0x8052A32: NodeMonitor::NodeMonitor(xercesc_3_0:OMNode*) (NodeMonitor.cpp:20)
==3926== by 0x8051824: Node::Node(xercesc_3_0:OMNode*) (Node.cpp:27)




Part of My code:
-----------------
valgrind showing leak in the following line:

id = "<" + responseId + ">";

NodeWatch::NodeWatch(Watch *watchInstance,string responseId, Threshold **thresholdArray, string pollinterval)
{
string id;
watch = watchInstance;
id = "<" + responseId + ">"; // Valgrind showing leak in this line
thresholds = thresholdArray;
pollInterval = atoi(pollinterval.c_str()) / 10;
}


Thanks,
Barani
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
looking for a fast STL-compliant memory-pool allocator ta0kira Programming 1 03-26-2009 04:02 PM
[SOLVED] Memory leak: How risky not to free allocated memory. kaz2100 Linux - General 1 12-24-2008 12:00 AM
Inactive memory issue, Freebsd (memory leak?) JasperB *BSD 7 08-12-2008 03:19 AM
memory leak ? os2 Programming 1 05-19-2005 01:45 PM
Memory Leak when using memory debugging C program on SuSE SLES8 babalina Linux - Distributions 0 10-06-2003 09:39 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration