Avoid declaring an object cannot fit in a segment if we already have committed space for it #55585
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The function
sufficient_space_end_seg
is used to check if we have sufficient space at the end of a segment to allocate a certain amount of space. The original implementation checks if we have sufficient reserved space, if not, we fail immediately, otherwise, we check for the hard limit, assuming all the space required has to be extra committed memory.But in many cases, the
ephemeral_heap_segment
has committed memory at its end already, we should consider those spaces first before we check if the extra commit fits within the hard limits.The change deliberately skips the region's case for now, which seems more complicated than I wanted for this change.