3 * GC related public interface
6 #ifndef __METADATA_MONO_GC_H__
7 #define __METADATA_MONO_GC_H__
9 #include <mono/metadata/object.h>
13 typedef int (*MonoGCReferences
) (MonoObject
*obj
, MonoClass
*klass
, uintptr_t size
, uintptr_t num
, MonoObject
**refs
, uintptr_t *offsets
, void *data
);
16 * This enum is used by the profiler API when reporting root registration.
20 * Roots external to Mono. Embedders may only use this value.
22 MONO_ROOT_SOURCE_EXTERNAL
= 0,
26 * The \c key parameter is a thread ID as a \c uintptr_t.
28 MONO_ROOT_SOURCE_STACK
= 1,
30 * Roots in the finalizer queue. This is a pseudo-root.
32 MONO_ROOT_SOURCE_FINALIZER_QUEUE
= 2,
34 * Managed \c static variables.
36 * The \c key parameter is a \c MonoVTable pointer.
38 MONO_ROOT_SOURCE_STATIC
= 3,
40 * Managed \c static variables with \c ThreadStaticAttribute.
42 * The \c key parameter is a thread ID as a \c uintptr_t.
44 MONO_ROOT_SOURCE_THREAD_STATIC
= 4,
46 * Managed \c static variables with \c ContextStaticAttribute.
48 * The \c key parameter is a \c MonoAppContext pointer.
50 MONO_ROOT_SOURCE_CONTEXT_STATIC
= 5,
52 * \c GCHandle structures.
54 MONO_ROOT_SOURCE_GC_HANDLE
= 6,
56 * Roots in the just-in-time compiler.
58 MONO_ROOT_SOURCE_JIT
= 7,
60 * Roots in the threading subsystem.
62 * The \c key parameter, if not \c NULL, is a thread ID as a \c uintptr_t.
64 MONO_ROOT_SOURCE_THREADING
= 8,
66 * Roots in application domains.
68 * The \c key parameter, if not \c NULL, is a \c MonoDomain pointer.
70 MONO_ROOT_SOURCE_DOMAIN
= 9,
72 * Roots in reflection code.
74 * The \c key parameter, if not \c NULL, is a \c MonoVTable pointer.
76 MONO_ROOT_SOURCE_REFLECTION
= 10,
78 * Roots from P/Invoke or other marshaling infrastructure.
80 MONO_ROOT_SOURCE_MARSHAL
= 11,
82 * Roots in the thread pool data structures.
84 MONO_ROOT_SOURCE_THREAD_POOL
= 12,
86 * Roots in the debugger agent.
88 MONO_ROOT_SOURCE_DEBUGGER
= 13,
90 * Roots in the runtime handle stack. This is a pseudo-root.
92 * The \c key parameter is a thread ID as a \c uintptr_t.
94 MONO_ROOT_SOURCE_HANDLE
= 14,
96 * Roots in the ephemeron arrays. This is a pseudo-root.
98 MONO_ROOT_SOURCE_EPHEMERON
= 15,
100 * Roots in the toggleref arrays. This is a pseudo-root.
102 MONO_ROOT_SOURCE_TOGGLEREF
= 16,
106 MONO_GC_HANDLE_TYPE_MIN
= 0,
107 MONO_GC_HANDLE_WEAK
= MONO_GC_HANDLE_TYPE_MIN
,
108 MONO_GC_HANDLE_WEAK_TRACK_RESURRECTION
,
109 MONO_GC_HANDLE_NORMAL
,
110 MONO_GC_HANDLE_PINNED
,
111 MONO_GC_HANDLE_TYPE_MAX
,
114 MONO_API
void mono_gc_collect (int generation
);
115 MONO_API
int mono_gc_max_generation (void);
116 MONO_API
int mono_gc_get_generation (MonoObject
*object
);
117 MONO_API
int mono_gc_collection_count (int generation
);
118 MONO_API
int64_t mono_gc_get_used_size (void);
119 MONO_API
int64_t mono_gc_get_heap_size (void);
120 MONO_API MonoBoolean
mono_gc_pending_finalizers (void);
121 MONO_API
void mono_gc_finalize_notify (void);
122 MONO_API
int mono_gc_invoke_finalizers (void);
123 /* heap walking is only valid in the pre-stop-world event callback */
124 MONO_API
int mono_gc_walk_heap (int flags
, MonoGCReferences callback
, void *data
);
126 MONO_API MONO_RT_EXTERNAL_ONLY
void
127 mono_gc_init_finalizer_thread (void);
130 * Only supported under SGen. These two with Sgen will take and release the LOCK_GC
132 void mono_gc_stop_world (void);
133 void mono_gc_restart_world (void);
137 #endif /* __METADATA_MONO_GC_H__ */