Re: How to find memory leaks from an running application

David Chapman <[email protected]>
Newsgroups gmane.comp.debugging.valgrind
Organization Chapman Consulting
Message-ID <[email protected]>
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.
>
> 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.

-- 
     David Chapman      [email protected]
     Chapman Consulting -- San Jose, CA
     EDA Software Developer, Expert Witness
     www.chapman-consulting-sj.com
     2018-2019 Chair, IEEE Consultants' Network of Silicon Valley



_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.