This is an old revision of the document!
To run Java on Mogon, you need to reserve much more memory than you think.
E.g. even for just calling
java -version with a specified maximum heap size (1GB in this example), you need to use the
Reserve5G application profile or Java won't start.
$ bsub -app Reserve5G -n 1 -q short java -Xmx1G -version
Note that for larger heap sizes, you just need to keep the offset large enough. For example, the “Reserve10G” profile is usually large enough to support a heap size of 5GB.
As Java creates additional threads for JVM maintainance (e.g. garbage collection) it is advisable to reserve an additional core for the Java overhead. I.e., if you have a single-threaded Java application, you should reserve a second CPU slot by using the -n 2 option. However, note that memory reserved via an -app profile is allocated per CPU slot, so you would end up reserving twice the memory you need. To reserve two CPU cores and 10 GB of total memory for a single process java program, you could reserve the total memory with the M option (in KB) and use the -R rusage option to specify that each process will nead 5 GB (written in MB) of memory. The span option makes sure both CPU slots are on the same machine.
bsub -n 2 -M 10485760 -R rusage[mem=5120] -R span[hosts=1] java -jar job.jar