C ++ / clang分析器内存泄漏? [英] C++/clang analyzer memory leaks?

查看:453
本文介绍了C ++ / clang分析器内存泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让clang ++告诉我有内存泄漏。我试过扫描构建,但它没有报告。我如何获得llvm / clang来警告我这个问题?

I'm trying to get clang++ to tell me there is a memory leak. I tried scan-build but it reported nothing. How do I get llvm/clang to warn me of this problem?

#include <iostream>

int main() {
        int *a = new int;
        *a = 8;
        std::cout<< a << std::endl;
}


推荐答案

有一些类似于保留段的程序所以对于小对象不需要扩展内存区域,尝试应用1024 * 1024 * 10然后检查结果

Because int is too small, there is something like one "reserved section" for program so for small object no need to extend memory area, try to apply 1024 * 1024 * 10 then check the result

这篇关于C ++ / clang分析器内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆