Attempts to instrument C++ code with IBM Rational Test RealTime result in memory leaks (MLK) reported outside of the instrumented code.
You see the memory leaks without any link to the source code in Test RealTime. You see the following description.
This behavior might be due to the construction of the static object with C++ code.
Resolving the problem
Most of the time the reported MLK are correct. MLK reported outside of the instrumented code are difficult to locate. To find them consider the following steps.
- Debug your application.
- Track blocks that the compiler has allocated when creating a class.
- Verify whether the compiler has released those blocks or not.
When testing C++ code, you could explain that Test RealITime can do an allocation at the construction of the static object. The message reports allocation of blocks before the entry program or after the exit. That means: the code has called malloc before the application starts. Therefore the pointer is not visible from the instrumented code. In that case you only have the size.Test RealTime can not link the code at the malloc, because it was not instrumented.
Instrumenting an application for memoryProfiling consists of multiple steps.
- Wrap the call to malloc/free (and other heap management functions) into all parsed files (even if they are not instrumented)
- Instrument all functions to create a chained list through the called methods in order to have the complete call stack available when the _atp_alloc get called.
- For C++ only: the wrap of the std new/delete. This step is done by the runtime through the std new delete redefinition.