Home > Net >  Valgrind - many allocated bytes
Valgrind - many allocated bytes

Time:10-11

Installed valgrind on my WSL and I was a bit confused.

Problem: I get a lot of allocated bytes even though my program doesn't do anything.

main.cpp:

#include <iostream>

using namespace std;

int main() {

     cout << "I'm testing valgrind!" << endl;
     return 0;
}

The result of calling valgrind:

==435== Memcheck, a memory error detector
==435== Copyright (C) 2002-2017, and GNU GPLd, by Julian Seward et al.
==435== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==435== Command: ./start
==435== 
==435== error calling PR_SET_PTRACER, vgdb might block 
I'm testing valgrind!
==435== 
==435== HEAP SUMMARY:
==435==     in use at exit: 0 bytes in 0 blocks
==435==   total heap usage: 2 allocs, 2 frees, 73,728 bytes allocated
==435== 
==435== All heap blocks were freed -- no leaks are possible
==435== 
==435== For lists of detected and suppressed errors, rerun with: -s
==435== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

I actually have two questions:

  1. Why do I get so many allocated bytes?
  2. How do I get rid of this? (In my univercity server valgrind doesn't show these bytes so I was wondering if I could do that too..)

CodePudding user response:

If you are curious and want to see what these allocations are, run with

--run-libc-freeres=no --run-cxx-freeres=no -s --leak-check=full --show-reachable=yes

As said in the comments, don't worry about this. All that matters are the errors.

  • Related