Linux Memory Consumption Hai Shalom http://www.rt-embedded.com
Licensing <ul><li>This presentation is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unite...
Attributions <ul><li>This presentation is based on the article “Linux memory consumption”, written by Hai Shalom and taken...
Where is all the free RAM? <ul><li>Traditional Unix tools like 'top‘ or ‘free’ often report a surprisingly small amount of...
So, where is it? <ul><li>Linux memory consumption concept is all about efficiency.  </li></ul><ul><li>The system’s RAM is ...
Continued <ul><li>Assuming there are no memory leaks, the reason that memory report tools report low amount of free memory...
The /proc/meminfo <ul><li>The kernel provides a special proc file called  meminfo , which displays the memory consumption ...
The /proc/meminfo important info <ul><li>MemTotal  -  Total  amount of physical RAM, in kilobytes.  </li></ul><ul><li>MemF...
Some facts <ul><li>The amount of  reclaimable  memory in the system, is the sum of  MemFree, Buffers  and  Cached . </li><...
Some facts - Continued <ul><li>Using unused (clean) cache for applications will not impact the system performance. </li></...
Flush and invalidate caches <ul><li>The following action increases the amount of  MemFree  by causing the kernel to drop c...
Flush and invalidate caches <ul><li>As this is a non-destructive operation, and dirty objects are not freeable, the user s...
Outcome of dropping caches
Kernel tunables regarding memory <ul><li>min_free_kbytes : Used to force the Linux VM to keep a minimum number of kilobyte...
Q&A <ul><li>Time to ask all the questions… </li></ul>
Thank you! <ul><li>The full article is available at the Real-Time embedded blog:  http://www.rt-embedded.com/blog/archives...
Backup slides
The /proc/meminfo in detail <ul><li>MemTotal  - Total amount of physical RAM, in kilobytes.  </li></ul><ul><li>MemFree  - ...
The /proc/meminfo in detail <ul><li>Inactive  - The total amount of buffer or page cache memory, in kilobytes, that are fr...
The /proc/meminfo in detail <ul><li>PageTables  — The total amount of memory, in kilobytes, dedicated to the lowest page t...
Próximos SlideShares
Carregando em…5
×

Linux memory consumption

9.533 visualizações

Publicada em

Linux memory consumption - Why memory utilities show a little amount of free RAM? How does Linux kernel utilizes free RAM? What is the real amount of free RAM in the system?

Publicada em: Tecnologia
0 comentários
3 gostaram
Estatísticas
Notas
  • Seja o primeiro a comentar

Sem downloads
Visualizações
Visualizações totais
9.533
No SlideShare
0
A partir de incorporações
0
Número de incorporações
99
Ações
Compartilhamentos
0
Downloads
155
Comentários
0
Gostaram
3
Incorporações 0
Nenhuma incorporação

Nenhuma nota no slide

Linux memory consumption

  1. 1. Linux Memory Consumption Hai Shalom http://www.rt-embedded.com
  2. 2. Licensing <ul><li>This presentation is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License. </li></ul><ul><li>Contributors to this document: </li></ul><ul><ul><li>Copyright © 2010 Hai Shalom – http://www.rt-embedded.com </li></ul></ul>
  3. 3. Attributions <ul><li>This presentation is based on the article “Linux memory consumption”, written by Hai Shalom and taken from the Real-Time Embedded blog: http://www.rt-embedded.com/blog/archives/linux-memory-consumption/ </li></ul>
  4. 4. Where is all the free RAM? <ul><li>Traditional Unix tools like 'top‘ or ‘free’ often report a surprisingly small amount of free memory after a system has been running for a while. Where does it all go? </li></ul><ul><li>You may be thinking that there are problems with memory leaks, or that your available RAM is being used inefficiently or even that your system does not have enough RAM to run correctly. </li></ul>
  5. 5. So, where is it? <ul><li>Linux memory consumption concept is all about efficiency. </li></ul><ul><li>The system’s RAM is a resource that is meant to be used; 100% of it (if possible), all the time (if possible). </li></ul><ul><li>Linux utilizes unused RAM to cache data and file system meta-data from slower storage devices (Flash or disk) because fetching the information from the RAM is much quicker </li></ul>
  6. 6. Continued <ul><li>Assuming there are no memory leaks, the reason that memory report tools report low amount of free memory is because the RAM is considered to be wasted if it isn’t used. </li></ul><ul><li>The kernel tries to utilize the most of the RAM to improve the system performance </li></ul>
  7. 7. The /proc/meminfo <ul><li>The kernel provides a special proc file called meminfo , which displays the memory consumption figures in details : </li></ul>
  8. 8. The /proc/meminfo important info <ul><li>MemTotal - Total amount of physical RAM, in kilobytes. </li></ul><ul><li>MemFree - The amount of physical RAM, in kilobytes, left unused by the system. </li></ul><ul><li>Buffers - The amount of physical RAM, in kilobytes, used for file buffers . </li></ul><ul><li>Cached - The amount of physical RAM, in kilobytes, used as cache memory . </li></ul>
  9. 9. Some facts <ul><li>The amount of reclaimable memory in the system, is the sum of MemFree, Buffers and Cached . </li></ul><ul><li>The Linux kernel will provide memory for applications, while reducing the amount of buffers and cached, if required. </li></ul>
  10. 10. Some facts - Continued <ul><li>Using unused (clean) cache for applications will not impact the system performance. </li></ul><ul><li>Degradation in the performance will appear once starting to free used cache. In some point (in the last free 1MB) the degradation will be very noticeable and the system will become very slow. </li></ul>
  11. 11. Flush and invalidate caches <ul><li>The following action increases the amount of MemFree by causing the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free. </li></ul><ul><ul><li>To free pagecache: </li></ul></ul><ul><ul><ul><li>echo 1 > /proc/sys/vm/drop_caches </li></ul></ul></ul><ul><ul><li>To free dentries and inodes: </li></ul></ul><ul><ul><ul><li>echo 2 > /proc/sys/vm/drop_caches </li></ul></ul></ul><ul><ul><li>To free pagecache, dentries and inodes: </li></ul></ul><ul><ul><ul><li>echo 3 > /proc/sys/vm/drop_caches </li></ul></ul></ul>
  12. 12. Flush and invalidate caches <ul><li>As this is a non-destructive operation, and dirty objects are not freeable, the user should run &quot;sync&quot; first in order to make sure all cached objects are freed. </li></ul><ul><li>This command does not free the currently used caches (like running processes). </li></ul>
  13. 13. Outcome of dropping caches
  14. 14. Kernel tunables regarding memory <ul><li>min_free_kbytes : Used to force the Linux VM to keep a minimum number of kilobytes free. </li></ul><ul><li>overcommit_memory : Controls over-commit of system memory, possibly allowing processes to allocate (but not use) more memory than is actually available. </li></ul>
  15. 15. Q&A <ul><li>Time to ask all the questions… </li></ul>
  16. 16. Thank you! <ul><li>The full article is available at the Real-Time embedded blog: http://www.rt-embedded.com/blog/archives/linux-memory-consumption/ </li></ul><ul><li>More information and articles are also available in the Real-Time Embedded blog </li></ul><ul><li>Contact me in the contact page , or send mail to: mailto:hai@rt-embedded.com </li></ul>
  17. 17. Backup slides
  18. 18. The /proc/meminfo in detail <ul><li>MemTotal - Total amount of physical RAM, in kilobytes. </li></ul><ul><li>MemFree - The amount of physical RAM, in kilobytes, left unused by the system. </li></ul><ul><li>Buffers - The amount of physical RAM, in kilobytes, used for file buffers. </li></ul><ul><li>Cached - The amount of physical RAM, in kilobytes, used as cache memory. </li></ul><ul><li>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. </li></ul>
  19. 19. The /proc/meminfo in detail <ul><li>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. </li></ul><ul><li>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. </li></ul><ul><li>Mapped — The total amount of memory, in kilobytes, which have been used to map devices, files, or libraries using the mmap command. </li></ul><ul><li>Slab — The total amount of memory, in kilobytes, used by the kernel to cache data structures for its own use. </li></ul><ul><li>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. </li></ul>
  20. 20. The /proc/meminfo in detail <ul><li>PageTables — The total amount of memory, in kilobytes, dedicated to the lowest page table level. </li></ul><ul><li>VMallocTotal — The total amount of memory, in kilobytes, of total allocated virtual address space. </li></ul><ul><li>VMallocUsed — The total amount of memory, in kilobytes, of used virtual address space. </li></ul><ul><li>VMallocChunk — The largest contiguous block of memory, in kilobytes, of available virtual address space. </li></ul>

×