I'm having a memory leak in the following piece of c++ code:
void onNewDepthSample(DepthNode node, DepthNode::NewSampleReceivedData data)
{
INT32 w, h;
FrameFormat_toResolution(data.captureConfiguration.frameFormat, &w, &h);
INT32 size = data.depthMap.size();
int16_t* ptr = new int16_t[size];
for (int i = 0; i < size; i++){
ptr[i] = data.depthMap[i];
}
depthCB(stringToCsharpString(node.getSerialNumber()), &w, &h, ptr);
delete[] ptr;
}
this method is called 30 times per second. Memory Leak Analysis:
Function details
Function DepthsenseDriver!malloc+49
Source Line
Allocation type Heap allocation(s)
Heap handle 0xcf11e4ac
Allocation Count 75256 allocation(s)
Allocation Size 1,22 MBytes
Leak Probability 100%
Call stack sample 1
Address 0x32335344
Allocation Time 00:05:00 since tracking started
Allocation Size 17 Bytes
Call stack:
DepthsenseDriver!malloc+49
DepthsenseDriver!operator new+1d
DepthsenseDriver!CreateFileW+96b
DepthsenseDriver!DepthSense::FunctionHandler<DepthSense::DepthNode,DepthSense::DepthNode::NewSampleReceivedData>::operator()+5d
I would like to know how I can interprete this analysis. For example, there is a CreateFileW function call, but in my code, this function call does not exist.
I am a C++ noob, so every tip or improvement is welcome :)
Using Deleaker, I discovered it was the stringToCsharpString method which caused the leak.