c++内存泄漏解释分析
C++ Memory Leak - interpreting analysis
下面这段c++代码有内存泄漏:
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;
}
这个方法每秒被调用30次。内存泄漏分析:
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
我想知道我该如何解释这个分析。例如,有一个CreateFileW函数调用,但在我的代码中,这个函数调用不存在。
我是一个c++新手,所以任何建议或改进都是欢迎的:)
使用Deleaker,我发现是stringToCsharpString方法导致了泄漏。
相关文章:
- valgrind-hellgrind与泄漏检查的结果不同
- 请解释"函数1(p1,p2,p3);"的输出
- 请解释这句话(cout<<1+int((a<b)^((b-a)&1) )<<endl
- 从构造函数抛出异常时如何克服内存泄漏
- malloc() 可能出现内存泄漏
- 被解释为低级别const的const对象的地址
- 计算每个节点的树高,帮助我解释这个代码解决方案
- MSVC将仅移动结构参数解释为指针
- 内联程序集printf将整数解释为地址
- 这个极客对极客的trie实现是否存在内存泄漏问题
- 有人能解释一下为什么下界是这样工作的吗C++的
- Visual Studio(或任何其他工具)能否将地址解释为调用堆栈(boost上下文)的开头
- 我是c ++的新手,你能解释一下在这种情况下的指针吗
- 有人能为我解释一下C++代码吗
- 尽管遵循了规则,内存泄漏在哪里
- Marshal.StructureToPtr出现无法解释的内存泄漏
- C++ Visual Studio - 在简单示例中解释内存泄漏检测
- 解释Valgrind内存泄漏总结日志
- 解释DrMemory日志,内存泄漏
- c++内存泄漏解释分析