Accounting for memory use in a running embedded Linux process

I have a Linux process that uses, say 16 MBytes of memory according to "top".

When I dump the executable using objdump, I can account for only, say, 7 MBytes of that. It's not doing much if any dynamic allocation ( a quick grep fest showed nothing at all, but I wouldn't trust that as truthful for the moment ).

What tools do I need to account for the difference? And why couldn't I Google something on the subject?

Thanks in advance.

-- Les Cargill

Reply to
Les Cargill
Loading thread data ...

Have a look at /proc/process_id/maps. Substitute 'process_id' with the number of your process.

It lists all memory areas mapped to your process.

The memory consumed by a process in a demand-paged virtual-memory system is pretty complicated, and there is no unique description what memory reservations must be accounted to the process.

Remember that physical memory is not consumed before an access is attempted to the page.

Also, what is the proper way of accounting for the memory areas consumed by shared libraries linked to several processes?

--

Tauno Voipio
Reply to
Tauno Voipio

Also, /proc/$PID/status will give a short summary of the totals of various types of allocation for the process.

You can only really take a system wide view of the total. If you try to account by process, you might say that a process uses X Mb of which Y is shareable, but how much of Y will actually be shared with other processes depends on what libraries they have in common. In practice libc will probably be shared of course, at the very least.

/proc/$PID/smaps will give a full breakdown of .../maps including which segments are shared or private, which bits of libraries are not fully resident as not all pages in it have been faulted into core, which bits are paged out to swap (though you probably don't have that on an embedded system of course) and much more that will only be of interest to serious memory tweakers.

Nick

--
"The Internet, a sort of ersatz counterfeit of real life"
	-- Janet Street-Porter, BBC2, 19th March 1996
Reply to
Nick Leverton

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.