@@ -2457,6 +2457,10 @@ BOOL gc_heap::verify_pinned_queue_p = FALSE;
2457
2457
2458
2458
uint8_t* gc_heap::oldest_pinned_plug = 0;
2459
2459
2460
+ #if defined(ENABLE_PERF_COUNTERS) || defined(FEATURE_EVENT_TRACE)
2461
+ size_t gc_heap::num_pinned_objects = 0;
2462
+ #endif //ENABLE_PERF_COUNTERS || FEATURE_EVENT_TRACE
2463
+
2460
2464
#ifdef FEATURE_LOH_COMPACTION
2461
2465
size_t gc_heap::loh_pinned_queue_tos = 0;
2462
2466
@@ -16360,6 +16364,10 @@ int gc_heap::garbage_collect (int n)
16360
16364
settings.reason = gc_trigger_reason;
16361
16365
verify_pinned_queue_p = FALSE;
16362
16366
16367
+ #if defined(ENABLE_PERF_COUNTERS) || defined(FEATURE_EVENT_TRACE)
16368
+ num_pinned_objects = 0;
16369
+ #endif //ENABLE_PERF_COUNTERS || FEATURE_EVENT_TRACE
16370
+
16363
16371
#ifdef STRESS_HEAP
16364
16372
if (settings.reason == reason_gcstress)
16365
16373
{
@@ -19869,10 +19877,30 @@ void gc_heap::pin_object (uint8_t* o, uint8_t** ppObject, uint8_t* low, uint8_t*
19869
19877
{
19870
19878
fire_etw_pin_object_event(o, ppObject);
19871
19879
}
19872
- #endif // FEATURE_EVENT_TRACE
19873
- COUNTER_ONLY(GetPerfCounters().m_GC.cPinnedObj ++);
19880
+ #endif // FEATURE_EVENT_TRACE
19881
+
19882
+ #if defined(ENABLE_PERF_COUNTERS) || defined(FEATURE_EVENT_TRACE)
19883
+ num_pinned_objects++;
19884
+ #endif //ENABLE_PERF_COUNTERS || FEATURE_EVENT_TRACE
19885
+ }
19886
+ }
19887
+
19888
+ #if defined(ENABLE_PERF_COUNTERS) || defined(FEATURE_EVENT_TRACE)
19889
+ size_t gc_heap::get_total_pinned_objects()
19890
+ {
19891
+ #ifdef MULTIPLE_HEAPS
19892
+ size_t total_num_pinned_objects = 0;
19893
+ for (int i = 0; i < gc_heap::n_heaps; i++)
19894
+ {
19895
+ gc_heap* hp = gc_heap::g_heaps[i];
19896
+ total_num_pinned_objects += hp->num_pinned_objects;
19874
19897
}
19898
+ return total_num_pinned_objects;
19899
+ #else //MULTIPLE_HEAPS
19900
+ return num_pinned_objects;
19901
+ #endif //MULTIPLE_HEAPS
19875
19902
}
19903
+ #endif //ENABLE_PERF_COUNTERS || FEATURE_EVENT_TRACE
19876
19904
19877
19905
void gc_heap::reset_mark_stack ()
19878
19906
{
0 commit comments