From: Howard C. <hy...@sy...> - 2019-06-20 10:32:28
|
David Chapman wrote: > On 6/19/2019 10:34 PM, subhasish Karmakar wrote: >> Hi, >> >> I have an application running on embedded linux. >> After running for hours my application causes out of memory issue. >> How can I get memory leak report periodically when the application is running? >> It's a process with "while(1)" loop. If your only problem is memory leaks and no other concerns (such as out of bounds accesses, corruptions, etc.) then you should give https://github.com/hyc/mleak/ a try. It is faster than all other memory leak detectors out there, fast enough to run in production. And you can send it a periodic signal to get a snapshot of currently allocated memory. >> >> Regards, >> Subhasish >> > > Valgrind reports leaks when the program exits. Because leaks are more than just memory that your program no longer references, there isn't a good way to report > leaks before your program exits. > > Your best bet is to build a version of your program that exits sooner, then run your embedded system until the program exits (vs. runs out of memory). Unless > your code leaks memory in very unusual circumstances, running it under valgrind for a few minutes should give you a lot of clues. Figure out how many times the > "while (1)" infinite loop iterates before the crash, divide that number by 100 or 1000, then replace the infinite loop with a "for (i = 0; i < count; ++i)" loop. > > Remember, your program will run slower under valgrind, so if your embedded system has strict real-time constraints it might not work properly. > -- -- Howard Chu CTO, Symas Corp. http://www.symas.com Director, Highland Sun http://highlandsun.com/hyc/ Chief Architect, OpenLDAP http://www.openldap.org/project/ |