Skip to content

Commit 826f318

Browse files
committed
DEBUG: Add logging of all allocation counts.
1 parent 115e00c commit 826f318

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

mono/metadata/appdomain.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3364,8 +3364,13 @@ unload_thread_main (void *arg)
33643364
* now be null we won't do any unnecessary copies and after
33653365
* the collection there won't be any more remsets.
33663366
*/
3367+
g_print("UnityAllocations");
33673368
for (i = 0; i < memory_manager->class_vtable_array->len; ++i)
3368-
zero_static_data ((MonoVTable *)g_ptr_array_index (memory_manager->class_vtable_array, i));
3369+
{
3370+
MonoVTable* vtable = (MonoVTable*)g_ptr_array_index(memory_manager->class_vtable_array, i);
3371+
g_print(" %zu %s\n", vtable->alloc_count, vtable->klass->name);
3372+
zero_static_data((MonoVTable*)g_ptr_array_index(memory_manager->class_vtable_array, i));
3373+
}
33693374
#if !HAVE_BOEHM_GC
33703375
mono_gc_collect (0);
33713376
#endif

mono/metadata/boehm-gc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,7 @@ mono_gc_alloc_obj (MonoVTable *vtable, size_t size)
995995
obj->vtable = vtable;
996996
}
997997

998+
vtable->alloc_count++;
998999
if (G_UNLIKELY (mono_profiler_allocations_enabled ()))
9991000
MONO_PROFILER_RAISE (gc_allocation, (obj));
10001001

@@ -1038,6 +1039,7 @@ mono_gc_alloc_vector (MonoVTable *vtable, size_t size, uintptr_t max_length)
10381039

10391040
obj->max_length = max_length;
10401041

1042+
vtable->alloc_count++;
10411043
if (G_UNLIKELY (mono_profiler_allocations_enabled ()))
10421044
MONO_PROFILER_RAISE (gc_allocation, (&obj->obj));
10431045

@@ -1075,6 +1077,7 @@ mono_gc_alloc_array (MonoVTable *vtable, size_t size, uintptr_t max_length, uint
10751077
if (bounds_size)
10761078
obj->bounds = (MonoArrayBounds *) ((char *) obj + size - bounds_size);
10771079

1080+
vtable->alloc_count++;
10781081
if (G_UNLIKELY (mono_profiler_allocations_enabled ()))
10791082
MONO_PROFILER_RAISE (gc_allocation, (&obj->obj));
10801083

@@ -1093,6 +1096,7 @@ mono_gc_alloc_string (MonoVTable *vtable, size_t size, gint32 len)
10931096
obj->length = len;
10941097
obj->chars [len] = 0;
10951098

1099+
vtable->alloc_count++;
10961100
if (G_UNLIKELY (mono_profiler_allocations_enabled ()))
10971101
MONO_PROFILER_RAISE (gc_allocation, (&obj->object));
10981102

mono/metadata/class-internals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ struct MonoVTable {
385385
MonoRuntimeGenericContext *runtime_generic_context;
386386
/* interp virtual method table */
387387
gpointer *interp_vtable;
388+
size_t alloc_count;
388389
/* do not add any fields after vtable, the structure is dynamically extended */
389390
/* vtable contains function pointers to methods or their trampolines, at the
390391
end there may be a slot containing the pointer to the static fields */

0 commit comments

Comments
 (0)