OutOfMemoryError in Ubuntu server


I have a server, written in java that working fine in Windows 7. But when I installed the same in Ubuntu, it shows out of memory error, server having 8 GB of ram and our server using only 70% of Ram, it shows out of memory error. And CPU usage is at the peak at out of memory time.

  1. How can I allocate the remaining 30 % of ram to my application?
  2. How can I increase the limit of memory that allocated to an application in Ubuntu?

Out of memory error does not occur in Windows, only Ubuntu. In the windows Task manager shows 100% CPU usage and full RAM usage. I wish to implement this performance in Ubuntu.


You can use ulimit to restrict the RAM usage for desired processes.

Additionally, for Java applications, you can pass arguments like -Xms (minimum), -Xmx (maximum) to java process (M for MBs, G for GBs).

By : Swapnil

This video can help you solving your question :)
By: admin