Skip to content

Add option GCTrimYoungestKeepPercent to specifies the percent of youngest gen to keep during trimming #109863

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 6 additions & 1 deletion src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44545,10 +44545,15 @@ void gc_heap::trim_youngest_desired_low_memory()
{
if (g_low_memory_status)
{
int keep_percent = static_cast<int>(GCConfig::GetGCTrimYoungestKeepPercent());
if ((keep_percent <= 0) || (keep_percent > 100))
{
keep_percent = 10;
}
size_t committed_mem = committed_size();
dynamic_data* dd = dynamic_data_of (0);
size_t current = dd_desired_allocation (dd);
size_t candidate = max (Align ((committed_mem / 10), get_alignment_constant(FALSE)), dd_min_size (dd));
size_t candidate = max (Align ((size_t)((committed_mem / 100.0) * keep_percent), get_alignment_constant(FALSE)), dd_min_size (dd));

dd_desired_allocation (dd) = min (current, candidate);
}
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/gc/gcconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class GCConfigStringHolder
STRING_CONFIG(GCHeapAffinitizeRanges, "GCHeapAffinitizeRanges", "System.GC.HeapAffinitizeRanges", "Specifies list of processors for Server GC threads. The format is a comma separated " \
"list of processor numbers or ranges of processor numbers. On Windows, each entry is " \
"prefixed by the CPU group number. Example: Unix - 1,3,5,7-9,12, Windows - 0:1,1:7-9") \
INT_CONFIG (GCTrimYoungestKeepPercent, "GCTrimYoungestKeepPercent", NULL, 10, "Specifies the percent youngest gen to keep during trimming") \
INT_CONFIG (GCHighMemPercent, "GCHighMemPercent", "System.GC.HighMemoryPercent", 0, "The percent for GC to consider as high memory") \
INT_CONFIG (GCProvModeStress, "GCProvModeStress", NULL, 0, "Stress the provisional modes") \
INT_CONFIG (GCGen0MaxBudget, "GCGen0MaxBudget", NULL, 0, "Specifies the largest gen0 allocation budget") \
Expand Down
Loading