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.

If the memory can't be allocated (out of memory), the program aborts with an error message written to the standard error.


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

If the memory can't be allocated (out of memory), the program aborts with an error message written to the standard error.


[View source]
def self.max_heap_size=(size : UInt64) : UInt64 #

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.


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

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.


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

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

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

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

[View source]