Re: [Valgrind-users] How to find memory leaks from an running application

2019-06-20 Thread David Faure
On jeudi 20 juin 2019 12:07:19 CEST Howard Chu wrote:
> 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.

Or, for another LD_PRELOAD-based tool with a really nice user interface on 
top, https://github.com/KDAB/heaptrack

-- 
David Faure, fa...@kde.org, http://www.davidfaure.fr
Working on KDE Frameworks 5





___
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users


Re: [Valgrind-users] How to find memory leaks from an running application

2019-06-20 Thread Philippe Waroquiers
On Thu, 2019-06-20 at 11:04 +0530, 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.

You can search leaks with valgrind while your program is running.

Different techniques can be used for that:
  * Inside your code, you add calls to client requests
such as VALGRIND_DO_LEAK_CHECK
  * From the shell, you can use 'vgdb' to launch
a leak search using the monitor request 'leak check'
  * Using gdb+vgdb, you can also launch such a leak check.
Compared to the previous techniques, the advantage is
that you can just put breakpoints where you want, and
launch leak searches when a breakpoints is reached.
You can also explore the 'logical leaks' (increase of
memory due to still reachable memory) using the monitor
request 'who_points_at'.

Note that these leak searches can show a 'delta leak' report,
i.e. pinpoint at the new allocations since the previous leak
search.

See user manual for more details, e.g.
http://www.valgrind.org/docs/manual/mc-manual.html#mc-manual.monitor-commands
and 
http://www.valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.gdbserver

Philippe

 


___
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users


Re: [Valgrind-users] How to find memory leaks from an running application

2019-06-20 Thread Howard Chu
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/


___
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users


Re: [Valgrind-users] How to find memory leaks from an running application

2019-06-20 Thread David Chapman

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  dcchap...@acm.org
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
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users