How to debug a strange memory leak (C ++)

I am writing a linux daemon, and currently it works very well, but it is leaking memory (and this is bad - after a few hours it segfaults after using 60% of the system memory). It is strange that I use only new / deleted operators and a try / catch block around the main function, so this is not an exception created by the new one - it is just segfaults at some point due to lack of memory, I think.

I used valgrind, but it found only a one-time small leak and nothing more. I also tried gdb, but despite the fact that the application is compiled with flags -g -rdynamic, it does not translate all addresses into function names.

Can you tell me some of the best ways to debug memory that I could use to determine the source of the leak?

+3
source share
8 answers

Valgrind is usually very reliable at finding leaks, so are you sure it's a memory leak?

The heap profiler can help you see which objects you are creating, and whether they are the ones you expect. Massif is one such tool that you might find useful.

+4
source

" " ++ , , . valgrind , , , , , . , , , .

valgrind, --show-reachable, , . , .

+3

, , , . , , - . / ( 32- , 2Gig?), ....

, , , . . , , .

0

gdb, # 1, , , segfault. , ( ulimit -c unlimited, , , , , ). gdb , , segfault (. backtrack).

0

(, , , , ). , ( ) , . , , , , .

0

, Valgrind , . , , โ€‹โ€‹ Valgrind .

"", , Java, . .. , , , , .. Valgrind , , .

0

- ? , libstd++? , libstd++ (5 6), .

0

, new NULL, , , . , segfault?

0
source

Source: https://habr.com/ru/post/1734134/


All Articles