Skip to content

Conversation

@LinHu2016
Copy link
Contributor

After some GCs, the number of Free regions could be smaller than desired number of Eden regions, which causes the number of reserved Regions is smaller than 0(reserved Region size = Free Region size - Eden Region size), correct Eden region size = Free region size for the case.

fix: #16413

@pshipton
Copy link
Member

pshipton commented Apr 4, 2023

@dmitripivkine @amicic

@amicic
Copy link
Contributor

amicic commented Apr 10, 2023

Ideally, I'd like to deal with these exceptional cases in core GC code rather than MXBean code. For example, getCurrentEdenSizeInBytes API should already handle the case when there is less free memory available than what desired Eden size is. There is already a lot of complexity to calculate desired size on core GC side, so adding this extra logic there is preferred - all that logic would be more centralized. Better than spill out a part of that complexity to MXBean.

That said, we already have a couple of more spots that we exceptionally handle in MXBean (race where we can allocate more than desired, and GC-end not properly reporting age 0 regions). So I'm ok we handle this exceptional case here, too. But in a long run this MXBean code should be simpler...

@LinHu2016
Copy link
Contributor Author

I agree that we should handle the exceptional case in core GC code, it would correct the reporting in verbose GC too.
before reportGCEnd, which triggers MXBean reporting , MM_SchedulingDelegate::calculateEdenSize() has been called, it updates current eden region count, looks like we can update maxEdenChange to prevent the exceptional case,

such as:
maxEdenChange = freeRegions; ==> maxEdenChange = freeRegions - _edenRegionCount;

maxEdenChange = maxHeapExpansionRegions; ==> maxEdenChange = maxHeapExpansionRegions + freeRegions - _edenRegionCount;

@LinHu2016 LinHu2016 force-pushed the correctMXBeanReport4edenSize branch from 6a5d3c7 to 4d791a4 Compare April 12, 2023 14:13
@LinHu2016 LinHu2016 force-pushed the correctMXBeanReport4edenSize branch 4 times, most recently from 54a1226 to 993ea77 Compare May 1, 2023 18:27
@LinHu2016 LinHu2016 force-pushed the correctMXBeanReport4edenSize branch 3 times, most recently from 331eb74 to 39512dd Compare May 15, 2023 19:43
@LinHu2016 LinHu2016 force-pushed the correctMXBeanReport4edenSize branch from 39512dd to 0613e61 Compare June 6, 2023 18:13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we expect (should we assert) freeRegions >= _edenRegionCount? if so, maxEdenChange could be unsigned

Copy link
Contributor Author

@LinHu2016 LinHu2016 Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

freeRegions could be smaller than _edenRegionCount. in that case, new _edenRegionCount could be smaller than old edenRegionCount(new _edenRegionCount = freeRegions).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that this comment moved to common path it needs to be adjusted. At least remove the leading sentence 'The heap is fully expanded', possibly adjust the rest of it, too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'/' could start at the line below

@LinHu2016 LinHu2016 force-pushed the correctMXBeanReport4edenSize branch from 0613e61 to a8250ff Compare June 7, 2023 18:37
After some GCs, the number of Free regions could be smaller than desired
number of Eden regions, which causes the number of reserved Regions is
smaller than 0(reserved Region size = Free Region size - Eden Region
size), correct Eden region size = Free region size for the case.

Signed-off-by: Lin Hu <linhu@ca.ibm.com>
@LinHu2016 LinHu2016 force-pushed the correctMXBeanReport4edenSize branch from a8250ff to da25f84 Compare June 7, 2023 18:40
@amicic
Copy link
Contributor

amicic commented Jun 7, 2023

jenkins test sanity win,aix jdk11

@amicic amicic merged commit 3543430 into eclipse-openj9:master Jun 8, 2023
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Jun 26, 2025
Pervious PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

fix case 1: maxHeapExpansionRegions could add on new eden region size
but it could cause reserved eden regions are more than free reqions.

fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Signed-off-by: lhu <linhu@ca.ibm.com>
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Jun 26, 2025
Pervious PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

fix case 1: maxHeapExpansionRegions could add on new eden region size
but it could cause reserved eden regions are more than free reqions.

fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Signed-off-by: lhu <linhu@ca.ibm.com>
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Jun 27, 2025
Pervious PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

fix case 1: maxHeapExpansionRegions could add on new eden region size
but it could cause reserved eden regions are more than free reqions.

fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Signed-off-by: lhu <linhu@ca.ibm.com>
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Jul 3, 2025
Pervious PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

fix case 1: maxHeapExpansionRegions could add on new eden region size
but it could cause reserved eden regions are more than free reqions.

fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Signed-off-by: lhu <linhu@ca.ibm.com>
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Jul 4, 2025
Pervious PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so add
shrinkDueToNoEnoughFree to
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange for
keeping free memory >= eden size after heap resize.

but it could cause reserved eden regions are more than free reqions.

fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Signed-off-by: lhu <linhu@ca.ibm.com>
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Jul 4, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so add
shrinkDueToNoEnoughFree to
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange for
keeping free memory >= eden size after heap resize.

fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Signed-off-by: lhu <linhu@ca.ibm.com>
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Jul 4, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so add
shrinkDueToNoEnoughFree to
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange for
keeping free memory >= eden size after heap resize.

fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Signed-off-by: lhu <linhu@ca.ibm.com>
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Aug 1, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
 for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion check to confirm free size >= eden size.

Signed-off-by: lhu <linhu@ca.ibm.com>
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Aug 11, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
 for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion checks to confirm free size >= eden size.

Signed-off-by: lhu <linhu@ca.ibm.com>
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Aug 12, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
 for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion checks to confirm free size >= eden size.

Signed-off-by: lhu <linhu@ca.ibm.com>
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Aug 15, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion check to confirm free size >= eden size.

Signed-off-by: lhu linhu@ca.ibm.com
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Aug 18, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion check to confirm free size >= eden size.

Signed-off-by: lhu linhu@ca.ibm.com
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Aug 19, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion check to confirm free size >= eden size.

Signed-off-by: lhu linhu@ca.ibm.com
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Aug 19, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion check to confirm free size >= eden size.

Signed-off-by: lhu linhu@ca.ibm.com
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Sep 3, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion check to confirm free size >= eden size.

Signed-off-by: lhu linhu@ca.ibm.com
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Sep 4, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion check to confirm free size >= eden size.

Signed-off-by: lhu linhu@ca.ibm.com
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Sep 10, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
 for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion checks to confirm free size >= eden size.

if the heap size change need to be adjusted due to enden size change and
adjusted heap change size is 0 and _heapSizingData.edenRegionChange > 0
( expending case), then need to set heap change size = edenRegionChange
to avoid eden size is bigger than free size issue.

Signed-off-by: lhu <linhu@ca.ibm.com>
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Sep 10, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
 for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion checks to confirm free size >= eden size.

if the heap size change need to be adjusted due to enden size change and
adjusted heap change size is 0 and _heapSizingData.edenRegionChange > 0
( expending case), then need to set heap change size = edenRegionChange
to avoid eden size is bigger than free size issue.

Signed-off-by: lhu <linhu@ca.ibm.com>
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Sep 10, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion check to confirm free size >= eden size.

Signed-off-by: lhu linhu@ca.ibm.com
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Sep 22, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion check to confirm free size >= eden size.

Signed-off-by: lhu linhu@ca.ibm.com
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Sep 24, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion check to confirm free size >= eden size.

Signed-off-by: lhu linhu@ca.ibm.com
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Sep 29, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion check to confirm free size >= eden size.

Signed-off-by: lhu linhu@ca.ibm.com
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Oct 2, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion check to confirm free size >= eden size.

Signed-off-by: lhu linhu@ca.ibm.com
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Oct 5, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion check to confirm free size >= eden size.

Signed-off-by: lhu linhu@ca.ibm.com
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Oct 15, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion check to confirm free size >= eden size.

Signed-off-by: lhu linhu@ca.ibm.com
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Oct 17, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
 for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion checks to confirm free size >= eden size.

if the heap size change need to be adjusted due to enden size change and
adjusted heap change size is 0 and _heapSizingData.edenRegionChange > 0
( expending case), then need to set heap change size = edenRegionChange
to avoid eden size is bigger than free size issue.

Signed-off-by: lhu <linhu@ca.ibm.com>
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Oct 29, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion check to confirm free size >= eden size.

Signed-off-by: lhu linhu@ca.ibm.com
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Dec 1, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
 for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion checks to confirm free size >= eden size.

if the heap size change need to be adjusted due to enden size change and
adjusted heap change size is 0 and _heapSizingData.edenRegionChange > 0
( expending case), then need to set heap change size = edenRegionChange
to avoid eden size is bigger than free size issue.

Signed-off-by: lhu <linhu@ca.ibm.com>
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Dec 1, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion check to confirm free size >= eden size.

Signed-off-by: lhu linhu@ca.ibm.com
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Dec 2, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
 for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion checks to confirm free size >= eden size.

Update to correct freeTenure at the beginning of PGC

should count out free eden size(for most case, free eden would be
closed to 0, but in some cases free eden is significant, it might
confuse the heap resize algorithm).

Signed-off-by: lhu <linhu@ca.ibm.com>
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Dec 2, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
 for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion checks to confirm free size >= eden size.

Update to correct freeTenure at the beginning of PGC

should count out free eden size(for most case, free eden would be
closed to 0, but in some cases free eden is significant, it might
confuse the heap resize algorithm).

Signed-off-by: lhu <linhu@ca.ibm.com>
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Dec 2, 2025
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
 for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion checks to confirm free size >= eden size.

Update to correct freeTenure at the beginning of PGC

should count out free eden size(for most case, free eden would be
closed to 0, but in some cases free eden is significant, it might
confuse the heap resize algorithm).

Signed-off-by: lhu <linhu@ca.ibm.com>
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Jan 2, 2026
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
 for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion checks to confirm free size >= eden size.

Update to correct freeTenure at the beginning of PGC

should count out free eden size(for most case, free eden would be
closed to 0, but in some cases free eden is significant, it might
confuse the heap resize algorithm).

Signed-off-by: lhu <linhu@ca.ibm.com>
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Jan 6, 2026
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
 for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion checks to confirm free size >= eden size.

Update to correct freeTenure at the beginning of PGC

should count out free eden size(for most case, free eden would be
closed to 0, but in some cases free eden is significant, it might
confuse the heap resize algorithm).

Signed-off-by: lhu <linhu@ca.ibm.com>
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Jan 6, 2026
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
 for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion checks to confirm free size >= eden size.

Update to correct freeTenure at the beginning of PGC

should count out free eden size(for most case, free eden would be
closed to 0, but in some cases free eden is significant, it might
confuse the heap resize algorithm).

Signed-off-by: lhu <linhu@ca.ibm.com>
LinHu2016 added a commit to LinHu2016/openj9 that referenced this pull request Jan 14, 2026
Previous PR eclipse-openj9#17107 target
to prevent exception "committed argument cannot be less than 0" for
MemoryPool "balanced-reserved" during collecting memoryUsage at the end
of GC(balanced GC only), but there are two special cases haven't been
covered.

Fix case 1: maxHeapExpansionRegions could add on maxEdenChange and use
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange to notify
heap resize to adjust heap size to match eden change, but it did not
consider the case which eden size is bigger than free memory, so update
_extensions->globalVLHGCStats._heapSizingData.edenRegionChange =
OMR_MIN(maxHeapExpansionRegions, edenChangeWithSurvivorHeadroom +
(intptr_t)(_edenRegionCount - freeRegions));
 for keeping free memory >= eden size after heap resize.

Fix case 2: eden region can not be smaller than 1, when free region is 0
eden region size can be 0.

Add Assertion checks to confirm free size >= eden size.

Update to correct freeTenure at the beginning of PGC

should count out free eden size(for most case, free eden would be
closed to 0, but in some cases free eden is significant, it might
confuse the heap resize algorithm).

Signed-off-by: lhu <linhu@ca.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mxbean gcNotification sometimes throw error while using balanced gc

3 participants