A desktop Ubuntu memory is 3G, but free has only 200M of memory and cannot meet the needs of Scala's JVM.
Note Use the top command to see the true free memory. Here's another command to see how much memory is actually used.
- Watch-n 1 Cat/proc/meminfo
Search found that there are three ways to achieve the purpose of freeing memory:
- Watch-n 1 free-m
- Or
- Free-m
The above method only increased by dozens of M.
- sudo sysctl-w vm.drop_caches=3
The purpose of this method is to release the memory that kernel uses on the cache. increased by about 1G.
The following method releases more, but may affect the stability of the system! Be sure to use it carefully.
- sudo sync && echo 3 | sudo tee/proc/sys/vm/drop_caches
This command releases either the memory in use or the cache (page cache, inodes, and Dentries), which is used with care.
In general, the second approach is more appropriate, and cron jobs can be used if it takes time to run automatically at intervals.
Release Ubuntu/linux system cache to increase available memory space