通过非常简单的C ++代码进行奇怪的alloc

时间:2018-03-09 18:25:23

标签: c++ valgrind

我最近了解了内存错误检查工具 Valgrind 。我检查了一些非常简单的C ++代码的allocs,发现了一些非常奇怪的有趣结果。例如,

#include<iostream>
using namespace std;

int main(){
        return 0;
}

valgrind输出是:

$ valgrind ./a.out 
==16952== Memcheck, a memory error detector
==16952== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==16952== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==16952== Command: ./a.out
==16952== 
==16952== 
==16952== HEAP SUMMARY:
==16952==     in use at exit: 72,704 bytes in 1 blocks
==16952==   total heap usage: 1 allocs, 0 frees, 72,704 bytes allocated
==16952== 
==16952== LEAK SUMMARY:
==16952==    definitely lost: 0 bytes in 0 blocks
==16952==    indirectly lost: 0 bytes in 0 blocks
==16952==      possibly lost: 0 bytes in 0 blocks
==16952==    still reachable: 72,704 bytes in 1 blocks
==16952==         suppressed: 0 bytes in 0 blocks
==16952== Rerun with --leak-check=full to see details of leaked memory
==16952== 
==16952== For counts of detected and suppressed errors, rerun with: -v
==16952== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

任何人都请在这一行解释神秘的分配:

==16952==   total heap usage: 1 allocs, 0 frees, 72,704 bytes allocated

0 个答案:

没有答案