Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to monitor memory usage of a process, and I want this data to be logged. Does such a tool exist?

share|improve this question
1  
    
The 2nd link appears dead. –  slm May 30 '13 at 4:12

6 Answers 6

up vote 6 down vote accepted

I have written an script to do exactly this: http://jeetworks.org/programs/syrupy.

It basically samples ps at specific intervals, to build up a profile of a particular process. The process can be launched by the monitoring tool itself, or it can be an independent process (specified by pid or command pattern).

share|improve this answer
    
Syrupy apparently moved to github.com/jeetsukumaran/Syrupy –  Framester Jul 23 at 10:49

sar (System Activity Reporter) from the sysstat package is your friend in case like these.

Another way would be monitoring combined with historical data, e.g. Munin, pnp4nagios, rrdtools, ...

share|improve this answer
    
but can sar be focussed on just one process? mostly it seems to monitor the system as a whole –  xenoterracide Jan 13 '11 at 15:38
1  
The pidstat command also from the sysstat package provides a fairly nice interface for reporting statistics on single process. –  Steven D Jan 13 '11 at 22:21
    
@xenoterracide Steven D had the answer. I wasn't aware of this command before. –  Christian Jan 14 '11 at 7:10

Besides the aforementioned sar, I'd recommend atop. It saves a binary log that you can peruse afterwards, and besides memory saves a lot of other information.

share|improve this answer

You could try Valgrind.

Valgrind is an instrumentation framework for building dynamic analysis tools. There are Valgrind tools that can automatically detect many memory management and threading bugs, and profile your programs in detail. You can also use Valgrind to build new tools.

The Valgrind distribution currently includes six production-quality tools: a memory error detector, two thread error detectors, a cache and branch-prediction profiler, a call-graph generating cache and branch-prediction profiler, and a heap profiler.

share|improve this answer
    
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. –  saji89 Jan 3 '13 at 8:36
    
This document massif explain in detail. –  Yantao Xie Feb 7 '13 at 7:23

Occasionally when the need arises I just do:

$ top -d 1 -b |grep <process> >>somefile

It's not an elegant solution, but gets the job done if you want the quick crude value to verify your hypothesis.

share|improve this answer

I think this link about programmatically monitoring a process memory usage will be useful for you to resolve your need.

share|improve this answer
4  
When you post a forum link like this, please also post a short summary, so that people immediately what your answer is about, and in case the forum goes away or changes its URLs. –  Gilles Jan 13 '11 at 20:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.