Mandar
Mandar

Reputation: 733

RAM analysis on Linux

I want to get the map of allocated memory in RAM running on Linux.

I am looking to find the utilization of memory at a given time as well as specifics of allocation in terms of user process and kernel modules and kernel itself.

Upvotes: 0

Views: 1549

Answers (2)

gby
gby

Reputation: 15218

This is very very hard to get right because of shared memory, caching and on demand paging.

You can indeed use /proc/PID/maps as the previous answer stated to learn that glibc, as an example, occupies a certain range of virtual memory in a certain process but part of that is shared between all processes mapping that library (the code section), part isn't (the dynamic linker tables, for example). Part of this memory space might not be in RAM at all (paged to disk) anc opy on write semantics might mean that the memory picture at the next moment might be very different.

Add do that the sophisticated use Linux makes in caching (the page and buffer caches being the major ones) which part of which can be evicted at the kernel whim (cache IO buffers which are not dirty) but some cannot (e.g. tmpfs pages) and it gets really hairy really quickly.

In short - no one good answer to get a true view of what uses RAM and for what in a Linux system. The best answer I know is pagemap and related tool. read all about it here: http://lwn.net/Articles/230975/

Upvotes: 2

p4553d
p4553d

Reputation: 818

You can find it out by checking ever process memory mapping

cat /proc/<PID>/maps

and for overall memory state

cat /proc/meminfo

Upvotes: 0

Related Questions