Monday, January 19, 2009

Monitoring Maximum Memory Usage in Linux

There are many tools available that can be used to monitor memory usage in computer programs. However, there are few tools that can be applied to monitor the memory usage of a specific process in an automated manner. Most memory monitoring tools provide a gui that a user can monitor.

However, these tools are not useful in contexts where memory must be monitored repeatedly. For example, automated software tests may require checks to validate that the memory usage does not exceed expected limits.

The memmon command is a new memory monitoring tool that is included in the UTILIB software library. memmon provides a convenient mechanism to report the maximum amount of memory that a process uses.

The memmon command requires the absolute path to the command that will be executed. Beyond that, its default syntax is quite simple:
$ ./memmon /bin/sleep 1
53768 Kb used

The memmon command can also be used to terminate a process whose memory exceeds a specified threshold:

$ ./memmon -k 10 /bin/sleep 1
./memmon: Error: memory exceeded
53764 Kb used

At present, memmon only supports memory monitoring on Linux platforms. However, it is not clear how its capability could be ported to other operating systems. I am particularly interested in this capability on MS Windows, if anyone has ideas for how to do that...

1 comment:

  1. I've been looking for a program like this for hours!
    Thanks for this post.