How to Fix High Memory Usage in Linux

How to Fix High Memory Usage in Linux


Our computers have more memory than they’ve ever had. Chances are good that this is true no matter when you’re reading this. That said, no matter how much memory you have, it never seems to be quite enough.
You can pack your computer or server full of all the RAM it will take, and something will always find a use for it. Most of the time this is a good thing. After all, what is the point of all that RAM if you don’t use it? On the other hand, if you’re limited, running out of memory can be a problem.

Are You Sure About Your Memory Usage?

Before you start looking to free up memory, you want to make sure that something is actually using it. Because of the way Linux handles memory, it just might seem like something is using all of your available memory.
Linux Fix High Memory Usage Top
As Linux Ate My RAM explains, the top command showing that you’re low on memory may not mean what you think it means. By default, Linux sets aside otherwise unused memory for disk caching, which actually helps speed up your computer.
That said, there could be some problematic services or applications that are actually using more RAM than they should be.

Diagnosing Memory Usage

To diagnose your memory, you’ll need to use a few different commands. The top command is good for looking at any applications that may be eating up too much RAM – just don’t rely solely on the PhysMem stat showing at the top.
You can use the free and ps commands to help diagnose any RAM issues, too. To use free, just run the following:
You’ll notice that the “total” and “used” figures will be similar. As we mentioned above, this is normal behavior for Linux, so don’t worry about this. The most important thing to pay attention to is the “used” section in the “buffers/cached” row, as this is what applications and services are actually using.
Linux Fix High Memory Usage Free
You can use ps similarly to top to determine which applications are using the most memory. To this, simply run the following:
This will show you which apps are using the most memory and show you their process IDs.
Linux Fix High Memory Usage Ps

Fixing Your High Memory Usage

There are a few common culprits when it comes to high memory usage on Linux. One of the main offenders is Java. Whether you’re using the official Java runtime environment or the GNU-supplied alternative, this can cause you trouble. If you’re running into this on a server, it could be caused by JBoss or Tomcat. You’ll find their configuration files somewhere like the following:
Other culprits can be Apache or MySQL. It’s beyond the scope of this article to show you exactly how to configure these, but you can check your log files for errors or warnings from these services.

Conclusion

If you’re looking for performance gains or to fix an issue, memory may not always be the culprit. It depends on what you’re looking for, but your solution could lie in another part of the computer entirely. Make sure you keep this in mind.

Comments

Popular posts from this blog

How are Cloud Storage, Cloud Backup, and Cloud Sync Different

How to Install Guest Additions in VirtualBox

10 Tips to Get the Most Out of Amazon