Wednesday, August 15, 2007

Understand Why Linux Uses Up All the Memory Resources

Have you ever wonder why your Linux uses up all the memory resources even though you don't run any applications? On the other hand in Windows, I see a lot more free memory resources. You give me an impression that your memory manager is better but why? Does Linux really sucks because of memory leak? Is it due to the fact that Linux is open source and therefore the quality is low?

I bought a Dell Machine sometimes ago and install the Linux Redhat on to that machine. The dell machine has 2 G of memory space. Therefore, I think it should be more than enough. However, after the machine turned on less than 24 hours, the free memory left only24 M bytes (see it from the top command) even though I killed all the applications.

Therefore, I made a conclusion that is the OS problems and it does not manage the memory efficiently and causes the memory leak. Even the application has memory leak, the OS should able to clean it up when the application exists. What a screw up Open Source OS? "You are really sucks and you let me down!", spoke in my mind. So what I did was to restart my Linux Machine everyday just to release the memory...

Interestingly after a few months, I only realized that I was wrong when I upgraded my memory to 4G. I realized that the free memory is also 19 M Bytes, same with my previous 2 G of memory space. "What's wrong?", I started to ask myself. So I started to investigate and finally found out that it is how the memory management works in Linux. It is not due to the memory leak and there is no memory leak in Linux.

The Linux kernel is designed in such a way that use most of the available RAM for buffers and cache in the system. Thus, most of the Linux system, you will see have a little small numbers (i.e 24320k) in the "free column" on the the "Mem:" line (see it from the top command). This free number will only be high immediately after booting, then drop to very little (i.e. 24320k) as you use the disk.


In fact, Linux's memory management is more efficient than the Windows. For example it takes 5 seconds to load an application for the first time and it becomes 2 seconds to load it the second time. As for Windows, you will take 5 seconds to load even for the second or third time.

In conclusion, if you notice your Linux uses up all the memory resources, don't worry. This is how Linux works. To have a better estimated used memory resources usage, it is better to refer to the buffers column rather than the free column in the top command. Lastly I would like to take this opportunity to apologize for blaming my dearest Linux that you're not doing a good job. I do not aware your memory manager is such a capable worker. You're still a very great OS. Keep up the good work!

2 Comments:

Anonymous said...

I do not aware of this as well. Thanks for the post. What a brilliant OS! Linux is always the best!

Anonymous said...

I was calling you names while reading the first two paras, but nice to read the later part of the blog. :-)
I wouldnt sit quiet if somebody says Linux is bad than Windows in managing memory.


Didn't find what you want? Use Google Search Engine below: