GC and memory allocation Strategy in JAVA

in most cases in JAVA, objects are allocated in Eden by default, and when GC is triggered, if there is not enough space in survivor, it will be put into the old age.
suppose the following scenario:
eden:80M survivor1:10M survivor2:10M
now survivor2 is empty, and then a total of 6m objects in eden survive, and a total of 5m objects survive in survivor1. Then we have a total of 11m things to survive, and the survivor2 only has a space size of 10m, so it is impossible to copy them all into survivor2. We need the old age, and the question is how many things should be copied into the old era, that is, all 11m things are copied into it. Or do you want to store 10m in survivor2 (assuming that the combination of objects can be just divided into 10m and 1m), and then store the remaining 1m of stuff in the old days. Is there an algorithm? Also, if 6m in eden is an object (that is, an object is 6m, no other objects), and an object in survivor1 is 5m, which objects are copied to survivor2 and which are copied to the old age? Is it stored according to the maximum 6m?


take a look and learn more about the JAVA virtual machine. At this time, the space allocation guarantee strategy will be implemented. His exact words go like this: bring objects that cannot be accommodated by survivor directly into the old age. So it should be full of survivor2.. Then deposit the remaining 1m into the old age.

there are extensions in parentheses, which you can skip (by the way, say a few more words). In minorgc. Jvm will check whether the remaining space in the old age is larger than the size of the surviving objects in this gc. For example, the remaining 1m objects above. In the old days, there was less than a trillion of space. Then check to see if the virtual machine is allowed to take risks (HandlePromotionFailure parameter). With permission. It will also check whether the average size of previous promotions to the old age is less than the maximum continuous available space in the current old age. If less than. Minorgc will be attempted. Otherwise, fullgc will be carried out directly. )

there is also the second case you mentioned. The large object that executes the jvm goes directly into the old policy (provided that the value of the-xx:PretenureSizeThreashold parameter is greater than 5m). If the old age cannot accommodate these two objects. Fullgc will be carried out. If not after fullgc. Then fullgc

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e46043-59bcc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e46043-59bcc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?