Check Leak using VmData
I want to Check Memory Leak.
I checked VmData of /proc/pid/status.
I deleted Heap Region but VmData was not changed.
Help me.
Below is my testCode.
#include <stdio.h>
#include <unistd.h>
enum MATRIX_TYPE {
MAT_TYPE_EMPTY=0, MAT_TYPE_REAL, MAT_TYPE_COMPLEX
};
template<class Type = float> class C2dMatrixIL {
protected:
Type *pr;
public:
C2dMatrixIL()
{
pr = 0;
}
~C2dMatrixIL()
{
C2dMatrixIL<Type>::Clear();
}
void SetSize(MATRIX_TYPE mat_type, int nrow, int ncol)
{
pr = new Type[nrow*ncol*MAT_TYPE_COMPLEX];
}
void Clear()
{
delete [] pr;
pr = 0;
}
};
int main() {
sleep(5);
while(1)
{
C2dMatrixIL<float> kk;
kk.SetSize(MAT_TYPE_COMPLEX,1000,1000);
printf("alloc state\n");
sleep(10);
kk.Clear();
printf("Clear state\n");
sleep(10);
}
return 0;
}
|
Last edited on
> I want to Check Memory Leak.
use valgrind
valgrind is a good tool to check memleak~
Topic archived. No new replies allowed.