Skip to content

Fix exception "committed argument cannot be less than 0"#24203

Open
LinHu2016 wants to merge 1 commit into
eclipse-openj9:masterfrom
LinHu2016:pmr_committedsizeisssue
Open

Fix exception "committed argument cannot be less than 0"#24203
LinHu2016 wants to merge 1 commit into
eclipse-openj9:masterfrom
LinHu2016:pmr_committedsizeisssue

Conversation

@LinHu2016

@LinHu2016 LinHu2016 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Previous PR #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).

  • In performResize() in case there is no heap resize, check if there is
    the case that free size is small than eden size due to the conflict
    between eden resize and heap resize, reCalculateEdenSize if it happens.

  • Fix zero-eden resize conflict in Balanced heap sizing.
    calculateEdenSize() to size eden using both current free regions and
    potential heap expansion. In the conflict case where eden sizing wants
    more expansion than heap sizing permits, eden is later recalculated
    without heap expansion allowance. If the post-heap-resize free space is
    zero, that recalculation can clamp eden to zero, which then leads to
    OOM. Fix this in checkResize() by detecting the zero-free-space conflict
    case before resize is finalized. When eden requires more growth than the
    chosen heap resize provides, and the resulting free space after heap
    resize would be zero, adjust the heap resize to edenSize - freeSize so
    the previously computed eden size is preserved.

fix : #23875
fix : #24037
fix : #22440

Signed-off-by: lhu linhu@ca.ibm.com

@LinHu2016 LinHu2016 force-pushed the pmr_committedsizeisssue branch from fd28666 to 7bfd9a9 Compare June 23, 2026 13:38
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).

 - In performResize() in case there is no heap resize, check if there is
the case that free size is small than eden size due to the conflict
between eden resize and heap resize, reCalculateEdenSize if it happens.

 - Fix zero-eden resize conflict in Balanced heap sizing.
calculateEdenSize() to size eden using both current free regions and
potential heap expansion. In the conflict case where eden sizing wants
more expansion than heap sizing permits, eden is later recalculated
without heap expansion allowance. If the post-heap-resize free space is
zero, that recalculation can clamp eden to zero, which then leads to
OOM. Fix this in checkResize() by detecting the zero-free-space conflict
case before resize is finalized. When eden requires more growth than the
chosen heap resize provides, and the resulting free space after heap
resize would be zero, adjust the heap resize to edenSize - freeSize so
the previously computed eden size is preserved.

Signed-off-by: lhu <linhu@ca.ibm.com>
@LinHu2016 LinHu2016 force-pushed the pmr_committedsizeisssue branch from 7bfd9a9 to 1e51e89 Compare June 23, 2026 15:40
@LinHu2016

Copy link
Copy Markdown
Contributor Author

@amicic @dmitripivkine please review the changes, Thanks

return _schedulingDelegate.getCurrentEdenSizeInBytes(env);
}

MMINLINE void reCalculateEdenSize(MM_EnvironmentVLHGC *env)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

fix spelling recalculateEdenSize

@amicic amicic added the comp:gc label Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment