相关疑难解决方法(0)

Valgrind:使用<iostream>可以通过简单的程序访问内存

采取以下琐碎的计划:

#include <iostream>
int main() {
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

如果我使用valgrind运行它,我被告知有72,704 bytes in 1 blocks那些still reachable.关于是否担心仍然可以达到警告的SO已经进行了广泛的讨论 - 我并不关心这一点.我只想了解当程序本身没有分配该库中的任何对象时,如何简单地包含标准库头可能会导致仍然可以访问的警告.

这是完整的valgrind输出:

$ valgrind --leak-check=full --track-origins=yes --show-reachable=yes ./ValgrindTest
==27671== Memcheck, a memory error detector
==27671== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==27671== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==27671== Command: ./ValgrindTest
==27671== 
==27671== 
==27671== HEAP SUMMARY:
==27671==     in use at exit: 72,704 bytes in 1 blocks
==27671== …
Run Code Online (Sandbox Code Playgroud)

c++ valgrind

68
推荐指数
3
解决办法
2万
查看次数

标签 统计

c++ ×1

valgrind ×1