# module GC

##
Defined in:

gc.cr
gc/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.

- .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(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

- .stats : GC::Stats

##
Class Method Detail

def self.add_finalizer(object : Reference) : Nil #
def self.add_finalizer(object) #
def self.add_root(object : Reference) #
def self.collect #
def self.disable #
def self.enable #
def self.free(pointer : Pointer(Void)) : Nil #
def self.init #
def self.is_heap_ptr(pointer : Pointer(Void)) : Bool #
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.

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.

def self.prof_stats #
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.

def self.register_disappearing_link(pointer : Pointer(Pointer(Void))) #
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

def self.stats : GC::Stats #