Skip to content
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

Decommit memory as needed #79912

Merged
merged 4 commits into from
Jan 11, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Decommit region before delete region
cshung committed Dec 23, 2022
commit 697d7134f43eb23e7b1296564370033c4f61e38d
39 changes: 24 additions & 15 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
@@ -20325,22 +20325,31 @@ bool gc_heap::try_get_new_free_region()
bool gc_heap::init_table_for_region (int gen_number, heap_segment* region)
{
#ifdef BACKGROUND_GC
dprintf (GC_TABLE_LOG, ("new seg %Ix, mark_array is %Ix",
heap_segment_mem (region), mark_array));
if (((region->flags & heap_segment_flags_ma_committed) == 0) &&
!commit_mark_array_new_seg (__this, region))
{
dprintf (GC_TABLE_LOG, ("failed to commit mark array for the new region %Ix-%Ix",
get_region_start (region), heap_segment_reserved (region)));
dprintf (GC_TABLE_LOG, ("new seg %Ix, mark_array is %Ix",
heap_segment_mem (region), mark_array));
if (((region->flags & heap_segment_flags_ma_committed) == 0) &&
!commit_mark_array_new_seg (__this, region))
{
dprintf (GC_TABLE_LOG, ("failed to commit mark array for the new region %Ix-%Ix",
get_region_start (region), heap_segment_reserved (region)));

// We don't have memory to commit the mark array so we cannot use the new region.
global_region_allocator.delete_region (get_region_start (region));
return false;
}
if ((region->flags & heap_segment_flags_ma_committed) != 0)
{
bgc_verify_mark_array_cleared (region, true);
}
// We don't have memory to commit the mark array so we cannot use the new region.
int h_number =
#ifdef MULTIPLE_HEAPS
heap_number;
#else
0;
cshung marked this conversation as resolved.
Show resolved Hide resolved
#endif
gc_oh_num oh = gen_to_oh (gen_number);
size_t size = heap_segment_committed(region) - heap_segment_mem (region);
virtual_decommit(heap_segment_mem (region), size, oh, h_number);
cshung marked this conversation as resolved.
Show resolved Hide resolved
global_region_allocator.delete_region (get_region_start (region));
return false;
}
if ((region->flags & heap_segment_flags_ma_committed) != 0)
{
bgc_verify_mark_array_cleared (region, true);
}
#endif //BACKGROUND_GC

if (gen_number <= max_generation)