LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 07-09-2008, 08:42 AM   #1
alanchansl
LQ Newbie
 
Registered: Jun 2006
Posts: 23

Rep: Reputation: 15
How to check the memory usage in an embedded Linux system?


Dear all,

Please help to suggest how to check the memory usage in an embedded Linux system, i.e how many remaining RAM size can be used?

Thank you very much.
Alan.
 
Old 07-09-2008, 08:55 AM   #2
alan_ri
Senior Member
 
Registered: Dec 2007
Location: Croatia
Distribution: Debian GNU/Linux
Posts: 1,733
Blog Entries: 5

Rep: Reputation: 127Reputation: 127
Hi,
Will free -m command do?
 
Old 07-09-2008, 11:02 AM   #3
jdines
LQ Newbie
 
Registered: Jul 2008
Posts: 19

Rep: Reputation: 0
If you have a kernel with proc filesystem support:

Code:
[jdines@msg ~]$ cat /proc/meminfo
MemTotal:       902028 kB
MemFree:         70584 kB
Buffers:         40568 kB
Cached:         425220 kB
SwapCached:       7772 kB
Active:         496664 kB
Inactive:       285564 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:       902028 kB
LowFree:         70584 kB
SwapTotal:     4089920 kB
SwapFree:      4061556 kB
Dirty:             236 kB
Writeback:           0 kB
AnonPages:      314520 kB
Mapped:          82816 kB
Slab:            35864 kB
SReclaimable:    24528 kB
SUnreclaim:      11336 kB
PageTables:       3372 kB
NFS_Unstable:        0 kB
Bounce:              0 kB
WritebackTmp:        0 kB
CommitLimit:   4540932 kB
Committed_AS:   656008 kB
VmallocTotal:   114680 kB
VmallocUsed:     10120 kB
VmallocChunk:   104424 kB
 
Old 07-10-2008, 11:37 AM   #4
alanchansl
LQ Newbie
 
Registered: Jun 2006
Posts: 23

Original Poster
Rep: Reputation: 15
First, thank you for all your replies.

Both of the method are tried.
For the information from /proc/meminfo, it is quite complicated to understand on each fields. Where can I find the definition on each field?
It is because I can't figure out the total memory that I have in system and how many left for usage.

For the free command, it is rather simple. I'll try on my appliation.

Please help to continue to support me if you have further information.

Alan.
 
Old 07-10-2008, 12:07 PM   #5
alan_ri
Senior Member
 
Registered: Dec 2007
Location: Croatia
Distribution: Debian GNU/Linux
Posts: 1,733
Blog Entries: 5

Rep: Reputation: 127Reputation: 127
Explanation for cat /proc/meminfo;
Quote:
High-Level Statistics
  • MemTotal: Total usable ram (i.e. physical ram minus a few reserved bits and the kernel binary code)
  • MemFree: Is sum of LowFree+HighFree (overall stat)
  • MemShared: 0; is here for compat reasons but always zero.
  • Buffers: Memory in buffer cache. mostly useless as metric nowadays
  • Cached: Memory in the pagecache (diskcache) minus SwapCache
  • SwapCache: Memory that once was swapped out, is swapped back in but still also is in the swapfile (if memory is needed it doesn't need to be swapped out AGAIN because it is already in the swapfile. This saves I/O)
Detailed Level Statistics
VM Statistics


VM splits the cache pages into "active" and "inactive" memory. The idea is that if you need memory and some cache needs to be sacrificed for that, you take it from inactive since that's expected to be not used. The vm checks what is used on a regular basis and moves stuff around.
When you use memory, the CPU sets a bit in the pagetable and the VM checks that bit occasionally, and based on that, it can move pages back to active. And within active there's an order of "longest ago not used" (roughly, it's a little more complex in reality). The longest-ago used ones can get moved to inactive. Inactive is split into two in the kernel. Some have it three.
  • Active: Memory that has been used more recently and usually not reclaimed unless absolutely necessary.
  • Inact_dirty: Dirty means "might need writing to disk or swap." Takes more work to free. Examples might be files that have not been written to yet. They aren't written to memory too soon in order to keep the I/O down. For instance, if you're writing logs, it might be better to wait until you have a complete log ready before sending it to disk.
  • Inact_clean: Assumed to be easily freeable. The kernel will try to keep some clean stuff around always to have a bit of breathing room.
  • Inact_target: Just a goal metric the kernel uses for making sure there are enough inactive pages around. When exceeded, the kernel will not do work to move pages from active to inactive. A page can also get inactive in a few other ways, e.g. if you do a long sequential I/O, the kernel assumes you're not going to use that memory and makes it inactive preventively. So you can get more inactive pages than the target because the kernel marks some cache as "more likely to be never used" and lets it cheat in the "last used" order.
Memory Statistics
  • HighTotal: is the total amount of memory in the high region. Highmem is all memory above (approx) 860MB of physical RAM. Kernel uses indirect tricks to access the high memory region. Data cache can go in this memory region.
  • LowTotal: The total amount of non-highmem memory.
  • LowFree: The amount of free memory of the low memory region. This is the memory the kernel can address directly. All kernel datastructures need to go into low memory.
  • SwapTotal: Total amount of physical swap memory.
  • SwapFree: Total amount of swap memory free.
  • Committed_AS: An estimate of how much RAM you would need to make a 99.99% guarantee that there never is OOM (out of memory) for this workload. Normally the kernel will overcommit memory. That means, say you do a 1GB malloc, nothing happens, really. Only when you start USING that malloc memory you will get real memory on demand, and just as much as you use. So you sort of take a mortgage and hope the bank doesn't go bust. Other cases might include when you mmap a file that's shared only when you write to it and you get a private copy of that data. While it normally is shared between processes. The Committed_AS is a guesstimate of how much RAM/swap you would need worst-case.
...and one more
Quote:

*

MemTotal — Total amount of physical RAM, in kilobytes.
*

MemFree — The amount of physical RAM, in kilobytes, left unused by the system.
*

Buffers — The amount of physical RAM, in kilobytes, used for file buffers.
*

Cached — The amount of physical RAM, in kilobytes, used as cache memory.
*

SwapCached — The amount of swap, in kilobytes, used as cache memory.
*

Active — The total amount of buffer or page cache memory, in kilobytes, that is in active use. This is memory that has been recently used and is usually not reclaimed for other purposes.
*

Inactive — The total amount of buffer or page cache memory, in kilobytes, that are free and available. This is memory that has not been recently used and can be reclaimed for other purposes.
*

HighTotal and HighFree — The total and free amount of memory, in kilobytes, that is not directly mapped into kernel space. The HighTotal value can vary based on the type of kernel used.
*

LowTotal and LowFree — The total and free amount of memory, in kilobytes, that is directly mapped into kernel space. The LowTotal value can vary based on the type of kernel used.
*

SwapTotal — The total amount of swap available, in kilobytes.
*

SwapFree — The total amount of swap free, in kilobytes.
*

Dirty — The total amount of memory, in kilobytes, waiting to be written back to the disk.
*

Writeback — The total amount of memory, in kilobytes, actively being written back to the disk.
*

Mapped — The total amount of memory, in kilobytes, which have been used to map devices, files, or libraries using the mmap command.
*

Slab — The total amount of memory, in kilobytes, used by the kernel to cache data structures for its own use.
*

Committed_AS — The total amount of memory, in kilobytes, estimated to complete the workload. This value represents the worst case scenario value, and also includes swap memory.
*

PageTables — The total amount of memory, in kilobytes, dedicated to the lowest page table level.
*

VMallocTotal — The total amount of memory, in kilobytes, of total allocated virtual address space.
*

VMallocUsed — The total amount of memory, in kilobytes, of used virtual address space.
*

VMallocChunk — The largest contiguous block of memory, in kilobytes, of available virtual address space.
*

HugePages_Total — The total number of hugepages for the system. The number is derived by dividing Hugepagesize by the megabytes set aside for hugepages specified in /proc/sys/vm/hugetlb_pool. This statistic only appears on the x86, Itanium, and AMD64 architectures.
*

HugePages_Free — The total number of hugepages available for the system. This statistic only appears on the x86, Itanium, and AMD64 architectures.
*

Hugepagesize — The size for each hugepages unit in kilobytes. By default, the value is 4096 KB on uniprocessor kernels for 32 bit architectures. For SMP, hugemem kernels, and AMD64, the default is 2048 KB. For Itanium architectures, the default is 262144 KB. This statistic only appears on the x86, Itanium, and AMD64 architectures.

Last edited by alan_ri; 07-10-2008 at 12:21 PM. Reason: adding info
 
Old 07-11-2008, 04:21 AM   #6
jdines
LQ Newbie
 
Registered: Jul 2008
Posts: 19

Rep: Reputation: 0
Post Links to the info posted by alan_ri for bookmarking

The information above is from the following two web pages, in case you want to bookmark them for later reference. I think that is more convienent than bookmarking a linuxquestions page. Your Mileage May Vary ;-)

http://www.redhat.com/advice/tips/meminfo.html

http://www.redhat.com/docs/manuals/e...c-meminfo.html
 
Old 07-11-2008, 08:11 AM   #7
alanchansl
LQ Newbie
 
Registered: Jun 2006
Posts: 23

Original Poster
Rep: Reputation: 15
Many Many thank you for all of your information. THANK YOU :-)

Alan.
 
Old 07-24-2008, 09:21 AM   #8
Micky_123
LQ Newbie
 
Registered: Dec 2007
Posts: 17

Rep: Reputation: 0
I think you can just use the TOP command. The top utility displays the memory info at the top of the screen and I believe top alos get this info. from the /proc/meminfo . So top can ease your life.

Cheers,
Micky
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to check memory usage on running process/applications rickylim Linux - General 17 05-08-2013 09:09 PM
Where is the missing 4M memory in my 16M embedded linux system?? ycvlee Linux - Kernel 0 10-18-2007 06:48 AM
most, er, universal way to get system memory total and usage lumix Linux - Newbie 1 06-03-2007 09:30 AM
System call to get current process memory usage? mattengland Programming 4 03-15-2006 07:07 PM
Who Customize Linux for an Embedded System usage? Rajaee Linux - Software 0 08-18-2003 03:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 08:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration