RFR: 8284900: Check InitialHeapSize and container memory limits before startup [v8]
Ioi Lam
iklam at openjdk.java.net
Wed Apr 20 18:37:38 UTC 2022
On Wed, 20 Apr 2022 16:10:12 GMT, xpbob <duke at openjdk.java.net> wrote:
>> Check InitialHeapSize and container memory limits before startup
>>
>>
>> Operating System Metrics:
>> Provider: cgroupv1
>> Effective CPU Count: 8
>> CPU Period: 100000us
>> CPU Quota: -1
>> CPU Shares: -1
>> List of Processors, 8 total:
>> 0 1 2 3 4 5 6 7
>> List of Effective Processors: N/A
>> List of Memory Nodes, 1 total:
>> 0
>> List of Available Memory Nodes: N/A
>> Memory Limit: 50.00M
>> Memory Soft Limit: Unlimited
>> Memory & Swap Limit: 60.00M
>> Maximum Processes Limit: 4194305
>>
>> command:-Xms60m -XshowSettings:system -version
>>
>>
>>
>>
>> When the memory limit is exceeded, the startup fail with message
>>
>>
>>
>> Error occurred during initialization of VM
>> Initial heap size set to a larger value than the container memory & swap limit
>
> xpbob has updated the pull request incrementally with one additional commit since the last revision:
>
> add test
Changes requested by iklam (Reviewer).
src/hotspot/share/gc/shared/gcArguments.cpp line 149:
> 147: if ((limit > 0) && (InitialHeapSize >= (julong) limit)) {
> 148: vm_exit_during_initialization("Initial heap size set to a larger value than the container memory & swap limit");
> 149: }
Since you are testing `InitialHeapSize >= (julong) limit)`, the error message should be:
> Initial heap size should be smaller than the container memory & swap limit
The JVM will use memory outside of the heap (for example malloc, or code cache), so even if you set the `InitialHeapSize` to below the memory limit, the JVM might still get killed by OOM unpredictably.
This PR catches obvious problems when `-Xms` is set way too large. However, I think we need to consider the larger issue of OOM killer when using Java in containers. I filed [JDK-8285277](https://bugs.openjdk.java.net/browse/JDK-8285277)
I've started a discussion on [hotspot-dev](https://mail.openjdk.java.net/pipermail/hotspot-dev/2022-April/059463.html) about what approach we should use to handle container memory limits. Let's hold on with this PR until we have a consensus.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8256
More information about the hotspot-gc-dev
mailing list