C ++ valgrind shows memory leak in hello world

My program code

#include <iostream>

int main(int argc, const char *argv[])
{
  std::cout << "hello world!\n";
  return 0;
}

I compiled it with flags

-Wpedantic -pedantic-errors -std=c++11 -g -Wall -Wextra

Run Valgrind on it and saw something strange, this simple program has a memory leak, the output of the command valgrind --leak-check=full --show-leak-kinds=all

==4492== 72,704 bytes in 1 blocks are still reachable in loss record 1 of 1
==4492==    at 0x4C28C20: malloc (vg_replace_malloc.c:296)
==4492==    by 0x4EBF11F: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
==4492==    by 0x400E9F9: call_init.part.0 (dl-init.c:78)
==4492==    by 0x400EAE2: call_init (dl-init.c:36)
==4492==    by 0x400EAE2: _dl_init (dl-init.c:126)
==4492==    by 0x40011C9: ??? (in /lib/x86_64-linux-gnu/ld-2.19.so)

my question is how to find out what is going on?

+4
source share
1 answer

, Linux. , , _dl_init(), : . , , break _init , , disassemble si, glibc .

(, , dup)

+2

All Articles