I was wondering if there was any way to allow more ram
Not more physical RAM, but you can increase the amount of system memory by using swap, which is a region of secondary storage. Traditionally on linux this is done with a small dedicated partition on a hard disk. Current Raspbian uses something similar, a swap file, which is just a normal file that's created at boot.
This is done by an init service,
dphys-swapfile (it's an old style SysV script in
/etc/init.d), named after the executable of the same name, which is documented in
man dphys-swapfile and configured in
/etc/dphys-swapfile. Here's the stock Raspbian version:
# /etc/dphys-swapfile - user settings for dphys-swapfile package
# author Neil Franklin, last modification 2010.05.05
# copyright ETH Zuerich Physics Departement
# use under either modified/non-advertising BSD or GPL license
# this file is sourced with . so full normal sh syntax applies
# the default settings are added as commented out CONF_*=* lines
# where we want the swapfile to be, this is the default
# set size to absolute value, leaving empty (default) then uses computed value
# you most likely don't want this, unless you have an special disk situation
# set size to computed value, this times RAM size, dynamically adapts,
# guarantees that there is enough swap without wasting disk space on excess
# restrict size (computed and absolute!) to maximally this limit
# can be set to empty for no limit, but beware of filled partitions!
# this is/was a (outdated?) 32bit kernel limit (in MBytes), do not overrun it
# but is also sensible on 64bit to prevent filling /var or even / partition
CONF_SWAPSIZE is uncommented, overriding the hardcoded default of "2 times RAM size". The number is in MiB. This makes sense on the Pi where the secondary storage is usually quite limited and creating a 1 or 2 GiB swap file would not be to many people's liking.
Obviously enough, you can change the number and reboot. You can then double check how much is available with
I don't use swap on the pi but I imagine it is going to be noticeably slower. Ideally the system stashes the least used stuff in there. That your processes are java based may mitigate that -- I like to believe the JVM's colossal mem gluttony is because it preps large chunks ready for use (hence, they aren't just virtual, but resident), much of which isn't necessarily used very often.
If the file is to be large, I guess it would be nice to reuse it and not have it created at boot, which my reading of the docs implies is the normal case. I could be wrong about that; if not you may want to dig around and see if this can be overridden.
If the performance is too bad and you only need less than an extra GB, you could instead use a zram based swap, which is a compressed region of RAM. This used to be the default on Raspbian. I do not know what the ratio is, but if it were e.g., 2:1, and you used ~250 GB, you'd end up with 1.25 GB, 0.5 GB of it in zram.
Sample raspberry-pi 3 zram gist (I haven't tried this, it's from a suggested edit by another user)