I think I found the problem. It seems valgrind doesn't detect memory leaks
related to mmap. Why is this the case?

On Thu, Jan 6, 2022 at 7:30 PM James Read <jamesread5...@gmail.com> wrote:

> I have a program that definitely has a memory leak. I can see the memory
> usage of the program going up rapidly with htop until it gets killed for
> consuming too much memory. Yet this is the output from sudo valgrind -v
> --tool=memcheck --leak-check=full --show-reachable=yes --track-origins=yes
> --log-file=memcheck.log ./my_mmap ip enp3s0 192.168.1.254 :
>
> ==234971==
> ==234971== HEAP SUMMARY:
> ==234971==     in use at exit: 235,528 bytes in 499 blocks
> ==234971==   total heap usage: 499,999 allocs, 499,500 frees, 18,248,456
> bytes allocated
> ==234971==
> ==234971== Searching for pointers to 499 not-freed blocks
> ==234971== Checked 4,186,197,696 bytes
> ==234971==
> ==234971== 235,528 bytes in 499 blocks are still reachable in loss record
> 1 of 1
> ==234971==    at 0x4843839: malloc (in
> /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==234971==    by 0x48F06DD: __fopen_internal (iofopen.c:65)
> ==234971==    by 0x48F06DD: fopen@@GLIBC_2.2.5 (iofopen.c:86)
> ==234971==    by 0x10A2B6: main (my_mmap.c:466)
> ==234971==
> ==234971== LEAK SUMMARY:
> ==234971==    definitely lost: 0 bytes in 0 blocks
> ==234971==    indirectly lost: 0 bytes in 0 blocks
> ==234971==      possibly lost: 0 bytes in 0 blocks
> ==234971==    still reachable: 235,528 bytes in 499 blocks
> ==234971==         suppressed: 0 bytes in 0 blocks
> ==234971==
> ==234971== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
>
> I attach the code for the program in question. It requires an input file
> with one IP address per line.
>
> Any ideas why this memory leak is not being detected by valgrind? Or what
> the source of the memory leak could be?
>
> James Read
>
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to