How the Nasal GC works: Difference between revisions

Jump to navigation Jump to search
Line 416: Line 416:
All high level type allocators (naNewString, naNewVector, naNewHash etc) make use of the naNew() call introduced earlier.
All high level type allocators (naNewString, naNewVector, naNewHash etc) make use of the naNew() call introduced earlier.


naNew() doesn't directly allocate new memory from the heap using naAlloc(), but instead use the naGC_get() helper which manages memory from the global pools (i.e. preallocated memory for each type).
naNew() doesn't directly allocate new memory from the heap using naAlloc(), but instead uses the naGC_get() helper which manages memory from the global pools (i.e. preallocated memory for each type).


For each native Nasal data type (scalars, vectors, hashes, funcs etc) , there are separate memory pools in globals->pools[n]. The index (n) is one of T_VEC, T_HASH, T_FUNC etc.
For each native Nasal data type (scalars, vectors, hashes, funcs etc) , there are separate memory pools in globals->pools[n]. The index (n) is one of T_VEC, T_HASH, T_FUNC etc.

Navigation menu