Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java heap space does not get increased using -Xmx 1g

I am doing some fancy stuff, where I really need to allocate about 1 GB.

My Computer has 8GB 64 bit System, so that's not a problem.

I use -Xmx 4g to increase my heap space, but sadly enough that doesn't work at all.

I use:

Runtime rt = Runtime.getRuntime();
long totalMem = rt.totalMemory();
long maxMem = rt.maxMemory();
long freeMem = rt.freeMemory();
double megs = 1048576.0;

System.out.println ("Total Memory: " + totalMem + " (" + (totalMem/megs) + " MiB)");
System.out.println ("Max Memory:   " + maxMem + " (" + (maxMem/megs) + " MiB)");
System.out.println ("Free Memory:  " + freeMem + " (" + (freeMem/megs) + " MiB)");

Which shows me:

Total Memory: 259522560 (247.5 MiB
Max Memory:   259522560 (247.5 MiB)
Free Memory:  0 (0 MiB)

I really don't know what I am doing wrong. Does anyone of you have an idea?

Thanks a lot!

like image 314
Daniel Avatar asked Jun 12 '26 06:06

Daniel


1 Answers

It is -Xmx4g, without a space in between.

like image 64
Thomas Jungblut Avatar answered Jun 14 '26 20:06

Thomas Jungblut