module GC

Defined in:

gc.cr
gc/boehm.cr
gc/none.cr

Class Method Summary

Class Method Detail

def self.add_finalizer(object : Reference) : Nil #

[View source]
def self.add_finalizer(object) #

[View source]
def self.add_root(object : Reference) #

[View source]
def self.collect #

[View source]
def self.disable #

[View source]
def self.enable #

[View source]
def self.free(pointer : Pointer(Void)) : Nil #

[View source]
def self.init #

[View source]
def self.is_heap_ptr(pointer : Pointer(Void)) : Bool #

[View source]
def self.malloc(size : Int) : Pointer(Void) #

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.


[View source]
def self.malloc_atomic(size : Int) : Pointer(Void) #

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.


[View source]
def self.prof_stats #

[View source]
def self.realloc(pointer : Pointer(T), size : Int) : Pointer(T) forall T #

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.

WARNING Memory allocated using Pointer.malloc must be reallocated using Pointer#realloc instead.


[View source]
def self.register_disappearing_link(pointer : Pointer(Pointer(Void))) #

[View source]
def self.set_stackbottom(stack_bottom : Pointer(Void)) #

this is necessary because Boehm GC does not use GC_stackbottom on Windows when pushing all threads' stacks; it also started crashing on Linux with libgc after v8.2.4; instead GC_set_stackbottom must be used to associate the new bottom with the running thread


[View source]
def self.stats : GC::Stats #

[View source]