0
   int main(){
    int *pointer = malloc(5);
    free(pointer);
    return 0;
}


 ==44611== 
==44611== HEAP SUMMARY:
==44611==     in use at exit: 22,223 bytes in 183 blocks
==44611==   total heap usage: 259 allocs, 76 frees, 28,335 bytes allocated
==44611== 
==44611== LEAK SUMMARY:
==44611==    definitely lost: 0 bytes in 0 blocks
==44611==    indirectly lost: 0 bytes in 0 blocks
==44611==      possibly lost: 0 bytes in 0 blocks
==44611==    still reachable: 0 bytes in 0 blocks
==44611==         suppressed: 22,223 bytes in 183 blocks
==44611== 

So as you can see from the code,there seems to be allocs and frees which i haven't done and a lot of bytes which have been allocated? Are these bytes now unusable by the computer,since i forgot to free them when i started programming in C? Also what does suppressed mean? And help to fix this issue.Thanks

Charana
  • 1,074
  • 1
  • 13
  • 26
  • 4
    Give this a read: http://stackoverflow.com/questions/8657337/what-do-the-suppressed-leaks-mean-in-valgrind – user4581301 Dec 01 '15 at 01:33
  • Ive read that and it doesn't really answer my question.The bytes allocated keep increasing everytime i run i program that mallocs without freeing.So its different from the link you just sent.Thanks – Charana Dec 01 '15 at 01:46
  • Memory should be given back under any modern Operating System on program termination, and even if it was not, I'm at a loss to see how a different execution could know about previously lost memory. Please build a minimal set of test code to replicate the problem and add it to your question so we can experiment and see what's up. – user4581301 Dec 01 '15 at 02:07
  • @user4581301 probably should of done that,sorry,thanks – Charana Dec 01 '15 at 02:09
  • Are you on Mac OSX by any chance? – kaylum Dec 01 '15 at 02:56
  • when asking a question about a runtime problem, post code that cleanly compiles, is short, and still exhibits the problem. The posted code is missing (at least) one #include statement. – user3629249 Dec 01 '15 at 03:54
  • note, the byte count passed to malloc() should be a multiple of the size of the pointer variable. in this case, suggest: `int *pointer = malloc(5*sizeof(int));`. This is mostly to avoid certain problems, like allocating less memory than is actually needed – user3629249 Dec 01 '15 at 03:57
  • per the linked question: 'The error-checking tools detect numerous problems in the system libraries, such as the C library, which come pre-installed with your OS. You can't easily fix these, but you don't want to see these errors (and yes, there are many!) So Valgrind reads a list of errors to suppress at startup. A default suppression file is created by the ./configure script when the system is built." Did you go through the configuration step when setting up valgrind? – user3629249 Dec 01 '15 at 04:03

0 Answers0