summaryrefslogtreecommitdiff
path: root/src/gc
diff options
context:
space:
mode:
authorMaoni Stephens <Maoni0@users.noreply.github.com>2019-10-03 12:44:36 -0700
committerGitHub <noreply@github.com>2019-10-03 12:44:36 -0700
commit97838277c6790c5c98f68772569790489967740c (patch)
tree0e983c17ed19bf7e328c7b5657e7d84a37f0f97a /src/gc
parente02a3e1c914f1a042c471a4195bc6e4428b0fb19 (diff)
downloadcoreclr-97838277c6790c5c98f68772569790489967740c.tar.gz
coreclr-97838277c6790c5c98f68772569790489967740c.tar.bz2
coreclr-97838277c6790c5c98f68772569790489967740c.zip
oom (#26457) (#26983)
+ when hardlimit is specified we should only retry when we didn't fail due to commit failure - if commit failed it means we simply didn't have as much memory as what the hardlimit specified. we should throw OOM in this case. + added some diag info around OOM history to help with future diagnostics. (cherry picked from commit 7dca41fd36721068e610c537654765e8e42275d7)
Diffstat (limited to 'src/gc')
-rw-r--r--src/gc/gc.cpp21
-rw-r--r--src/gc/gcpriv.h11
2 files changed, 31 insertions, 1 deletions
diff --git a/src/gc/gc.cpp b/src/gc/gc.cpp
index f49366474e..ec2b855ff6 100644
--- a/src/gc/gc.cpp
+++ b/src/gc/gc.cpp
@@ -2611,6 +2611,10 @@ exclusive_sync* gc_heap::bgc_alloc_lock;
oom_history gc_heap::oom_info;
+int gc_heap::oomhist_index_per_heap = 0;
+
+oom_history gc_heap::oomhist_per_heap[max_oom_history_count];
+
fgm_history gc_heap::fgm_result;
size_t gc_heap::allocated_since_last_gc = 0;
@@ -10917,6 +10921,8 @@ gc_heap::init_gc_heap (int h_number)
ephemeral_heap_segment = 0;
+ oomhist_index_per_heap = 0;
+
freeable_large_heap_segment = 0;
condemned_generation_num = 0;
@@ -12146,6 +12152,17 @@ size_t gc_heap::limit_from_size (size_t size, uint32_t flags, size_t physical_li
return new_limit;
}
+void gc_heap::add_to_oom_history_per_heap()
+{
+ oom_history* current_hist = &oomhist_per_heap[oomhist_index_per_heap];
+ memcpy (current_hist, &oom_info, sizeof (oom_info));
+ oomhist_index_per_heap++;
+ if (oomhist_index_per_heap == max_oom_history_count)
+ {
+ oomhist_index_per_heap = 0;
+ }
+}
+
void gc_heap::handle_oom (int heap_num, oom_reason reason, size_t alloc_size,
uint8_t* allocated, uint8_t* reserved)
{
@@ -12175,6 +12192,7 @@ void gc_heap::handle_oom (int heap_num, oom_reason reason, size_t alloc_size,
oom_info.available_pagefile_mb = fgm_result.available_pagefile_mb;
oom_info.loh_p = fgm_result.loh_p;
+ add_to_oom_history_per_heap();
fgm_result.fgm = fgm_no_failure;
// Break early - before the more_space_lock is release so no other threads
@@ -13775,7 +13793,8 @@ exit:
if (loh_alloc_state == a_state_cant_allocate)
{
assert (oom_r != oom_no_failure);
- if (should_retry_other_heap (size))
+
+ if ((oom_r != oom_cant_commit) && should_retry_other_heap (size))
{
loh_alloc_state = a_state_retry_allocate;
}
diff --git a/src/gc/gcpriv.h b/src/gc/gcpriv.h
index c194c547b6..5099d6ca0c 100644
--- a/src/gc/gcpriv.h
+++ b/src/gc/gcpriv.h
@@ -2908,6 +2908,17 @@ public:
// End DAC zone
+#define max_oom_history_count 4
+
+ PER_HEAP
+ int oomhist_index_per_heap;
+
+ PER_HEAP
+ oom_history oomhist_per_heap[max_oom_history_count];
+
+ PER_HEAP
+ void add_to_oom_history_per_heap();
+
PER_HEAP
BOOL expanded_in_fgc;