I have a c++ program and I want to tracking the heap memory when running
int MyFunction(){
//do function logic here
//do function logic here
.....................
//Check memory state in heap at the end of function
_CrtMemState crtMemState;
_CrtMemCheckpoint(&crtMemState);
printf("Memory: %d\n",crtMemState.lTotalCount);
}
int main(){
while(true){//Yes infinitive for long run test
MyFunction();
}
}
I got the result of memory :
Memory: 47435440
Memory: 76571670
Memory: 105710436
Memory: 135412510
Memory: 164726468
Memory: 194256398
Memory: 223569972
......
It's mean that the memory is increase for each function execution. Does this mean MyFunction() has leak? I tried some method like visual leak detector or _CRT* relate function but have no report about leak. My program running with memory increase by time ( I used PerfMonitor to check)