Skip to content

Commit b117a3d

Browse files
authored
Merge pull request #815 from Unity-Technologies/unity-master-profiler-gc-allocations
Add legacy profiler support for allocations (case 988906) Return in Boehm 0 for number of managed allocators. If GC has no managed allocators, allow allocation profiling to be set lazily. case 988906 - Fix GC allocation profiling
2 parents 31039ff + c7ff206 commit b117a3d

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

mono/metadata/boehm-gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,7 @@ mono_gc_get_managed_allocator_by_type (int atype, ManagedAllocatorVariant varian
13071307
guint32
13081308
mono_gc_get_managed_allocator_types (void)
13091309
{
1310-
return ATYPE_NUM;
1310+
return 0;
13111311
}
13121312

13131313
MonoMethod*

mono/metadata/profiler.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ mono_profiler_sampling_thread_wait (void)
559559
mono_bool
560560
mono_profiler_enable_allocations (void)
561561
{
562-
if (mono_profiler_state.startup_done)
562+
if (mono_gc_get_managed_allocator_types () > 0 && mono_profiler_state.startup_done)
563563
return FALSE;
564564

565565
return mono_profiler_state.allocations = TRUE;
@@ -1105,6 +1105,9 @@ mono_profiler_set_events (int flags)
11051105
else
11061106
mono_profiler_set_call_instrumentation_filter_callback (current->handle, NULL);
11071107
/* Do nothing. */
1108+
1109+
if (flags & MONO_PROFILE_ALLOCATIONS)
1110+
mono_profiler_enable_allocations ();
11081111
}
11091112

11101113
static void

0 commit comments

Comments
 (0)