D
Language
Phobos
Comparisons
object
std
std.base64
std.boxer
std.compiler
std.conv
std.ctype
std.date
std.file
std.format
std.gc
std.intrinsic
std.math
std.md5
std.mmfile
std.openrj
std.outbuffer
std.path
std.process
std.random
std.recls
std.regexp
std.socket
std.socketstream
std.stdint
std.stdio
std.cstream
std.stream
std.string
std.system
std.thread
std.uri
std.utf
std.zip
std.zlib
std.windows
std.linux
std.c
std.c.stdio
std.c.windows
std.c.linux
|
std.gc
The garbage collector normally works behind the scenes without
needing any specific interaction. These functions are for
advanced applications that benefit from tuning the operation of the
collector.
- class OutOfMemory
- Thrown if garbage collector runs out of memory.
- void addRoot(void* p)
- Add p to list of roots. Roots are references to memory
allocated by the collector that are maintained in memory
outside the collector pool. The garbage collector will by
default look for roots in the stacks of each thread, the registers,
and the default static data segment. If roots are held elsewhere,
use addRoot() or addRange() to tell the collector
not to free the memory it points to.
- void removeRoot(void* p)
- Remove p from list of roots.
- void addRange(void* pbot, void* ptop)
- Add range to scan for roots.
- void removeRange(void* pbot)
- Remove range.
- void fullCollect()
- Run a full garbage collection cycle.
The collector normally runs synchronously with a storage
allocation request (i.e. it never happens when in code that
does not allocate memory). In some circumstances, for example
when a particular task is finished, it is convenient to explicitly
run the collector and free up all memory used by that task.
It can also be helpful to run a collection before starting a new
task that would be annoying if it ran a collection in
the middle of that task.
Explicitly running a collection can also be done in a separate very low priority
thread, so that if the program is idly waiting for input, memory
can be cleaned up.
- void genCollect()
- Run a generational garbage collection cycle.
Takes less time than a fullCollect(), but isn't
as effective.
- void minimize()
- Minimize physical memory usage.
- void disable()
- Temporarilly disable garbage collection cycle.
This is used for brief time critical sections of code,
so the amount of time it will take is predictable.
If the collector runs out of memory while it is disabled,
it will throw an OutOfMemory exception.
The disable() function calls can be nested, but must be
matched with corresponding enable() calls.
- void enable()
- Reenable garbage collection cycle after being disabled
with disable().
It is an error to call more enable()s than
disable()s.
|