go to  ForumEasy.com   
JavaPro  
 
 
   Home  |  MyForum  |  FAQ  |  Archive    You are not logged in. [Login] or [Register]  
Forum Home » Java Deploying » Linux Memory Management
Email To Friend  |   Set Alert To This Topic Rewarding Points Availabe: 0 (What's this) New Topic  |   Post Reply
Author Topic: Linux Memory Management
Linux
member
offline   
 
posts: 120
joined: 01/24/2011
from: San Jose, CA
  posted on: 09/12/2012 07:54:09 PM    Edit  |   Quote  |   Report 
Linux Memory Management
You can use free to find out all memory allocated to your Linux box and how many memory your applications can use.

# free -m
             total       used       free     shared    buffers     cached
Mem:           595        382        212          0        132        190
-/+ buffers/cache:         59        535
Swap:            0          0          0


To explain the output, let's consider the general case:
# free -m
             total       used       free     shared    buffers     cached
Mem:           A           B          C          0        D          E
-/+ buffers/cache:         F          G
Swap:           0          0          0


Here comes the facts:
  • A -- the total memory allocated to your Linux box.
  • D+E -- buffers/cached memory gracefully occupied by system in case there are availabe.
  • G(=C+D+E) -- free memory your apps can use.
  • F(=B-D-E or =A-G) -- used memory by your apps.

  •  Profile | Reply Points Earned: 0
    Linux
    member
    offline   
     
    posts: 120
    joined: 01/24/2011
    from: San Jose, CA
      posted on: 09/12/2012 07:55:00 PM    Edit  |   Quote  |   Report 
    How many total memory is allocated to my Linux box?
    That is A=595 (MB).
    # free -m | grep 'Mem' | tr -s ' ' | cut -d ' ' -f 2
    


     Profile | Reply Points Earned: 0
    Linux
    member
    offline   
     
    posts: 120
    joined: 01/24/2011
    from: San Jose, CA
      posted on: 09/12/2012 07:56:08 PM    Edit  |   Quote  |   Report 
    How many more memory my applications can still use?
    That is G=535 (MB).
    # free -m | grep 'buffers/cache' | tr -s ' ' | cut -d ' ' -f 4
    

     Profile | Reply Points Earned: 0
    Linux
    member
    offline   
     
    posts: 120
    joined: 01/24/2011
    from: San Jose, CA
      posted on: 09/12/2012 07:56:52 PM    Edit  |   Quote  |   Report 
    How many memory my applications have used?
    That is F=59 (MB).
    # free -m | grep 'buffers/cache' | tr -s ' ' | cut -d ' ' -f 3
    

     Profile | Reply Points Earned: 0
    Linux
    member
    offline   
     
    posts: 120
    joined: 01/24/2011
    from: San Jose, CA
      posted on: 09/12/2012 07:57:26 PM    Edit  |   Quote  |   Report 
    How to force the buffers/cached memory to release?
    # echo 3 > /proc/sys/vm/drop_caches
    


    Run free again:
    # free -m
                 total       used       free     shared    buffers     cached
    Mem:           595         52        542          0          0          8
    -/+ buffers/cache:         43        551
    Swap:            0          0          0
    

     Profile | Reply Points Earned: 0

     
    Powered by ForumEasy © 2003-2005, All Rights Reserved. | Privacy Policy | Terms of Use
     
    Get your own forum today. It's easy and free.