Module mun_runtime::gc[][src]

Exposes Mun garbage collection.

Structs

GcPtr

A GcPtr is what you interact with outside of the allocator. It is a pointer to a piece of memory that points to the actual data stored in memory.

UnsafeTypeInfo

UnsafeTypeInfo is a type that wraps a NonNull<TypeInfo> and indicates unsafe interior operations on the wrapped TypeInfo. The unsafety originates from uncertainty about the lifetime of the wrapped TypeInfo.

Functions

mun_gc_alloc

Allocates an object in the runtime of the given type_info. If successful, obj is set, otherwise a non-zero error handle is returned.

mun_gc_collect

Collects all memory that is no longer referenced by rooted objects. If successful, reclaimed is set, otherwise a non-zero error handle is returned. If reclaimed is true, memory was reclaimed, otherwise nothing happend. This behavior will likely change in the future.

mun_gc_ptr_type

Retrieves the type_info for the specified obj from the runtime. If successful, type_info is set, otherwise a non-zero error handle is returned.

mun_gc_root

Roots the specified obj, which keeps it and objects it references alive. Objects marked as root, must call mun_gc_unroot before they can be collected. An object can be rooted multiple times, but you must make sure to call mun_gc_unroot an equal number of times before the object can be collected. If successful, obj has been rooted, otherwise a non-zero error handle is returned.

mun_gc_unroot

Unroots the specified obj, potentially allowing it and objects it references to be collected. An object can be rooted multiple times, so you must make sure to call mun_gc_unroot the same number of times as mun_gc_root was called before the object can be collected. If successful, obj has been unrooted, otherwise a non-zero error handle is returned.