-
Notifications
You must be signed in to change notification settings - Fork 733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gencon occurs OOME when creating new String but other GC policies does not. #17445
Comments
@amicic FYI |
@BurryPotter, thanks for reporting this problem. However, for the most part this is expected behaviour of gencon. It’s mostly a side effect of a couple of things:
Gencon’s Nursery default size is up to 1/4 of total heap. Tenure default size is up to total heap size. But once heap is fully expanded, we don’t not allow changing that boundary between Tenure and Nursery. In this case the heap is fully expanded (Xms==Xmx), so for the duration of the run the fixed ratio of 3-to-1 is maintained (3GB Tenure, 1G Nursery). In a case of heap gradually expanding the ratio could be different, so that Tenure space is more then 3/4 of the total heap (for example 3.5G Tenure and 0.5G Nurseru), but again, if heap gets fully expanded, and while it stays fully expanded the ratio does not change. The test case, after filling up the heap, will remove 100MB of objects, but it will be young objects (by virtue of doing removeLast), hence freeing up all memory in Nursery and none in Tenure. Hence, the pre-tenure allocation fails, without an attempt to expand Tenure (at the cost of Nursery). Some workaround, to at least validate the statements and better understand how gencon’s sizing work:
In theory, we could perhaps fix this behaviour, by for example allowing Tenure to expand at the cost of Nursery contraction to satisfy a pre-tenure allocation (if Nursery has some free space, which is indeed the case here). And it’s been a consideration to allow Tenure expansion (at the cost of Nursery) for many year, but it’s not as trivial as it may sound, and we will probably not allow it any time soon. Allowing interned-string allocation from Nursery would also be a major change in behaviour, even less likely to happen. Overall, for the time being, we should just accept this behaviour as per design (and if acceptable for your real-live scenarios, work around it, with more or less suggestions I provided). |
Thank you for your response. It appears to be an issue caused by the design and may be challenging to resolve within a short period of time. I will make modifications to my code to avoid similar problems in the future. |
Closing it as working as designed, and no plans to change the behaviour any time soon. |
I'd like to reopen this issue. In this test program, it clearly has free memory available, yet it fails to allocate strings. |
@dmitripivkine, I assume you intended to reopen this issue when you moved it to the Deep Backlog milestone. If not, please close it. |
Java -version output
java -version
openjdk version "1.8.0_362"
IBM Semeru Runtime Open Edition (build 1.8.0_362-b09)
Eclipse OpenJ9 VM (build openj9-0.36.0, JRE 1.8.0 Windows 11 amd64-64-Bit Compressed References 20230207_599 (JIT enabled, AOT enabled)
OpenJ9 - e68fb24
OMR - f491bbf6f
JCL - eebde685ec based on jdk8u362-b09)
Summary of problem
The Gencon collector appears to encounter difficulties in creating new String when there is limited remaining memory available.
During program execution, I continue to allocate memory until an OutOfMemoryError (OOME) is triggered. And then I release 100MB of space and create new simple strings. But it throws OOME again when I create new strings. Interestingly, if I don't use the Gencon collector and instead use a different collector, I am able to create strings successfully.
Furthermore, I had tested it on JDK8, JDK11 and JDK17 (But the information provided later is from JDK8), and found that the Gencon collector throws an OOME (OutOfMemoryError) when creating strings, while other collectors can successfully create strings. Maybe, the GenCon collector handles string allocation differently, which could explain the OutOfMemoryError (OOME) during string creation.
Reproduce step
Case.java
After releasing 100MB of memory, the program should have enough space to create this short string
"Allocate " + mb + "MB memory."
without throwing an OOME.Diagnostic files
I run the following command, and then upload the dump files to Google Driven. dump files
OutOfMemoryError: Java Heap Space
I run the following command to get details informations, witch is writed into
gencongc.log
file gencongc.logThe text was updated successfully, but these errors were encountered: