Skip to content

Commit

Permalink
Add option GCTrimYoungestKeepPercent to specifies the percent of youn…
Browse files Browse the repository at this point in the history
…gest gen to keep during trimming
  • Loading branch information
ashaurtaev committed Jan 31, 2025
1 parent 847a8c2 commit 8d4aef9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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

0 comments on commit 8d4aef9

Please sign in to comment.