|
|
1.1 ! root 1: .TH GALLOC 3 ! 2: .CT 2 mem_man ! 3: .SH NAME ! 4: galloc, gfree, garbage \(mi storage allocation with garbage collection ! 5: .SH SYNOPSIS ! 6: .nf ! 7: .B char *galloc(n) ! 8: .B unsigned n; ! 9: .PP ! 10: .B void gfree(p) ! 11: .B char *p; ! 12: .PP ! 13: .B void garbage() ! 14: .fi ! 15: .SH DESCRIPTION ! 16: These functions perform heap storage allocation with ! 17: garbage collection. ! 18: .PP ! 19: .I Galloc ! 20: allocates a block of at least ! 21: .I n ! 22: bytes and returns a pointer to it. ! 23: .I Gfree ! 24: frees a block previously allocated by ! 25: .I galloc. ! 26: .PP ! 27: When space gets tight, garbage blocks ! 28: are freed automatically. ! 29: A block allocated by ! 30: .I galloc ! 31: is deemed to be garbage unless it is reachable. ! 32: A reachable block is one whose first byte is ! 33: pointed to by a declared C variable ! 34: or by a pointer in a reachable block. ! 35: .PP ! 36: The frequency of garbage collection is controlled by external ! 37: variables declared ! 38: .IP ! 39: .B "long gcmax = 5000, gcmin = 50;" ! 40: .LP ! 41: No more than ! 42: .I gcmax ! 43: allocations may intervene between automatic collections; this feature ! 44: will help contain the growth of virtual address space. ! 45: At least ! 46: .I gcmin ! 47: allocations must intervene, otherwise ! 48: garbage collection will be abandoned as fruitless. ! 49: .I Garbage ! 50: may be called to do garbage collection at an arbitrary time. ! 51: .PP ! 52: .IR Malloc (3) ! 53: and ! 54: .I galloc ! 55: allocate from the same arena, but garbage collection ! 56: affects only ! 57: .I galloc ! 58: blocks. ! 59: .I Free ! 60: (see ! 61: .IR malloc (3)) ! 62: must not be used on blocks allocated with ! 63: .IR galloc . ! 64: .SH SEE ALSO ! 65: .IR malloc (3) ! 66: .SH DIAGNOSTICS ! 67: .I Galloc ! 68: returns 0 ! 69: when space cannot be found. ! 70: .SH BUGS ! 71: Garbage collection is conservative; ! 72: blocks that appear to be pointed to from ! 73: within declared storage will not be freed, ! 74: regardless of whether the apparent `pointers' ! 75: were declared as such.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.