module GC
Defined in:
gc.crgc/boehm.cr
gc/none.cr
Class Method Summary
-
.collect : Nil
Collect the HEAP memory now, instead ofwaiting until the HEAP is full.
-
.disable : Nil
Disables GC collections.
-
.enable : Nil
Enables GC collections.
-
.malloc(size : Int) : Pointer(Void)
Allocates and clearssize bytes of memory.
-
.malloc_atomic(size : Int) : Pointer(Void)
Allocatessize bytes of pointer-free memory.
-
.prof_stats
Returns extended profiling statistics about the HEAP memory and GC collections.
-
.realloc(pointer : Pointer(T), size : Int) : Pointer(T) forall T
Changes the allocated memory size ofpointer tosize.
-
.stats : GC::Stats
Returns statistics about the current HEAP memory.
Class Method Detail
Disables GC collections. The GCwill always increase the HEAP sizewhen the
HEAP is full. CallGC.enable as many times asGC.disablewas called to
reenable GC collections.
Enables GC collections. This is the default behavior. The GCwill collect
memorywhen the HEAP is full. Must be called as many times asGC.disable
was called.
Allocates and clearssize bytes of memory.
The resulting object may contain pointers and theywill be tracked by the GC.
The memorywill be automatically deallocatedwhen unreferenced.
If the memory can't be allocated (out of memory), the program abortswith an error messagewritten to the standard error.
Allocatessize bytes of pointer-free memory.
The client promises that the resulting objectwill never contain any pointers.
The memory is not cleared. Itwill be automatically deallocatedwhen unreferenced.
If the memory can't be allocated (out of memory), the program abortswith an error messagewritten to the standard error.
Returns extended profiling statistics about the HEAP memory and GC collections.
Changes the allocated memory size ofpointer tosize. If this can't be done in place, it allocatessize bytes of memory and copies the content ofpointer to the new location.
Ifpointerwas allocatedwith.malloc_atomic, the same constraints apply.
The return value is a pointer that may be identical topointer or different.
If the memory can't be allocated (out of memory), the program abortswith an error messagewritten to the standard error.
WARNING Memory allocated usingPointer.malloc must be reallocated using
Pointer#realloc instead.