IBM Support

Memory leaks when using STL container classes implemented by the GNU C++ library

Troubleshooting


Problem

In this situation IBM® Rational® Test RealTime® reports a memory leak. This happens when you use the Standard Template Library (STL) container classes, vector, list, and others, implemented in the GNU C++ library. You see this even though the code destroys the container object at the end of the function. Consider the following example code. [] #include #include #include using namespace std; main() { vector v(6); /*[] MLK : Memory leaked here []*/ for (int j=0; j<6; j++) { v[j] = j; cout << j << ": " << v[j] << endl; } v.clear(); } [] Test RealTime reports a memory leak at the declaration of []v[] even though the code destroys it at the end of the function.

[{"Product":{"code":"SSSHUF","label":"Rational Test RealTime"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Component":"Not Applicable","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"}],"Version":"2002.05.00;2002.05.20;2003.06.00;2003.06.01;2003.06.12;2003.06.13;2003.06.15;7.0;7.0.0.1","Edition":"","Line of Business":{"code":"LOB77","label":"Automation Platform"}}]

Log InLog in to view more of this document

This document has the abstract of a technical article that is available to authorized users once you have logged on. Please use Log in button above to access the full document. After log in, if you do not have the right authorization for this document, there will be instructions on what to do next.

Document Information

Modified date:
16 June 2018

UID

swg21160634