Will java use more memory when working on a machine with more RAM

If I have a smaller car and a larger car. I run the same Java code on them. Will jvm make garbage collection more lazy on a machine with a big bar?

The problem I'm trying to solve is the memory problem. People have reported that they have a memory problem on a small machine. I want to check it out, but the only machine I currently have is much more than theirs. I am wondering if I am running a test on this larger machine and monitoring the memory usage, will the memory usage be the same on the smaller machine or will it use even less memory?

Thanks! Erben

+4
source share
3 answers

You need to look at the JVM memory parameters. in fact, you can install as much memory as you want for your JVM:

-Xmx2048m -> this param to set the max memory that the JVM can allocate
-Xms1024m -> the init memory that JVM will allocate on the start up
-XX:MaxPermSize=512M -> this for the max Permanent Generation memory

therefore, in your case, you can install a large memory, like on another machine. therefore, you will not receive more RAM than the Xmx value

and you can also check these parameters.

-XX:MaxNewSize=  -> this need to be 40% from your Xmx value
-XX:NewSize=614m -> this need to be 40% from your Xmx value

you can also tell the JVM which type of GC to use as:

-XX:+UseConcMarkSweepGC

SO, if you set these parameters on both machines, you will get the same results and the same GC activity.

+5
source

, . . , :

java -XshowSettings:vm

(Windows 8.1, 4 , 32--Java-Runtime) 247,5 , (Windows 7, 8 , 64--Java-Runtime) 903,12 .

Java (. fooobar.com/questions/13542/..., , , ).

, vm -RAM-, -Xmx, (, -Xmx128m RAM 128 ).

, Out Of Memory, ( ) , , .

+3

The problem can be reproduced with more RAM.

First you need to get the heap size configuration from the people who reported the problem. Use the same heap size to reproduce the problem.

Use below jvm params for heap settings.

-Xmx512m   Max heap memory that is used to store objects
-XX:MaxPermSize=64m   Max perm gen size. This space is used to store meta info like loaded classes etc
+2
source

Source: https://habr.com/ru/post/1523855/


All Articles