I really need to define the minimum heap size for Java

I'm about to deploy the application to the real-time server, and now I'm in the part of setting the heap and permgen size for the JVM I've read many articles. Everyone says "set the minimum heap size to (a number)" and "set the maximum heap size to (a number)", but these articles do not explain why the minimum heap size needs to be set I understand the reason for setting the maximum heap size, but not the minimum heap size I would appreciate it if you knew something about it

Solution

Heap in Java is a general memory allocation area Let's assume that we set the minimum heap size to 1000 bytes (an absurdly low number) Now let me say that I instantiate an object in my program that contains some text with a length of 2000 characters I cannot save this object without first expanding the heap size Now, my maximum heap parameter is probably large enough to allow this - but that's why I set the maximum heap size

However, assuming my server has 4G ram, I set the minimum heap size to (an absurd big number.) This will work if no other programs occupy any memory However, if I use my java program to start the second process, it will not allocate enough memory and exit

The minimum size can do two things for you; First, it makes memory available quickly for quick startup Second, it allows you to adjust your JVM so that you have some invariants that allow you to predict how many processes you can run If your minimum heap size is too large, you may waste memory on a process that never needs so much, thus limiting the capacity of the system If it is set too small, the program will take a long time to start, which will have a negative impact on the performance of the process

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>