You can show used, free, total, and max memory (RAM) available in a Scala application just like you do in Java. The lines of code look like this:
Java memory FAQ: How do I control the amount of memory my Java program uses (i.e., Java RAM usage)?
One of the Linux servers that I use is a little starved for memory, but I need to run a Java program on it periodically to run some utility tasks. However, every time I try to run the program I get this Java heap size error message:
How do I show the free memory on a Linux system?
You can show free memory on a Linux system with the
free command, like this:
That command returns results like this:
total used free shared buffers cached Mem: 8145044 8097552 47492 0 74252 1189464 -/+ buffers/cache: 6833836 1311208 Swap: 12578884 6205424 6373460
If you prefer to see information in MB you can use the
-m parameter, like this: