module GC
Defined in:
gc.crgc/boehm.cr
gc/none.cr
Class Method Summary
- .add_finalizer(object : Reference) : Nil
- .add_finalizer(object)
- .add_root(object : Reference)
- .collect
- .disable
- .enable
- .free(pointer : Pointer(Void)) : Nil
- .init
- .is_heap_ptr(pointer : Pointer(Void)) : Bool
-
.malloc(size : Int) : Pointer(Void)
Allocates and clears size bytes of memory.
-
.malloc_atomic(size : Int) : Pointer(Void)
Allocates size bytes of pointer-free memory.
-
.max_heap_size=(size : UInt64) : UInt64
Limit the heap size to size bytes.
- .prof_stats
-
.realloc(pointer : Pointer(T), size : Int) : Pointer(T) forall T
Changes the allocated memory size of pointer to size.
- .register_disappearing_link(pointer : Pointer(Pointer(Void)))
- .set_stackbottom(thread_handle : Pointer(Void), stack_bottom : Pointer(Void))
- .set_stackbottom(thread : Thread, stack_bottom : Pointer(Void))
- .stats : GC::Stats
Class Method Detail
Allocates and clears size bytes of memory.
The resulting object may contain pointers and they will be tracked by the GC.
The memory will be automatically deallocated when unreferenced.
If the memory can't be allocated (out of memory), the program aborts with an error message written to the standard error.
Allocates size bytes of pointer-free memory.
The client promises that the resulting object will never contain any pointers.
The memory is not cleared. It will be automatically deallocated when unreferenced.
If the memory can't be allocated (out of memory), the program aborts with an error message written to the standard error.
Limit the heap size to size bytes.
Useful when you are debugging, especially on systems that do not handle
running out of memory well. Or as an alternative to the environment variable
GC_MAX_HEAP_SIZE.
A zero size means the heap is unbounded; this is the default.
This implementation rejects any other value than 0.
Changes the allocated memory size of pointer to size. If this can't be done in place, it allocates size bytes of memory and copies the content of pointer to the new location.
If pointer was allocated with .malloc_atomic, the same constraints apply.
The return value is a pointer that may be identical to pointer or different.
If the memory can't be allocated (out of memory), the program aborts with an error message written to the standard error.
WARNING Memory allocated using Pointer.malloc must be reallocated using
Pointer#realloc instead.