Valgrind shows std::vector<> times of alloc is more than free, but no memory leak

后端 未结 3 1484
春和景丽
春和景丽 2021-01-20 22:29

The code is fairly simple:

#include 
int main() {
    std::vector v;
}

Then I build and run it with Valgrind:

3条回答
  •  情书的邮戳
    2021-01-20 22:48

    (1) A properly implemented default constructed std::vector doesn't allocate. Esp not 72k. Try running with --leak-check=full --track-origins=yes , perhaps it shows the origin of the allocation

    (2) It says it, see: still reachable. The memory is not (yet) leaked, since there's still a handle (e.g: a pointer) pointing to it.

    (3) It is the process id of the application.

提交回复
热议问题