[CM] s7 finalization

bil at ccrma.Stanford.EDU bil at ccrma.Stanford.EDU
Tue Dec 31 02:45:55 PST 2019

Since you mention valgrind, I assume you're seeing it report memory
leaks in s7 functions such as mallocate, alloc_symbol, petrify,
add_opt_func, etc -- these are not "leaks" in the sense that memory
is lost inadvertently.  s7 allocates blocks of memory, then manages
local allocations itself (malloc and free are slow).  I think that
valgrind sees that the pointer returned by malloc is no longer
accessible, and reports it as a leak.

The most likely s7-related memory leak involves s7_gc_protect.
If you call this, then for some reason don't call the corresponding
s7_gc_unprotect_at, the internal table of protected objects grows.
You can see if this is happening by calling (*s7* 'memory-usage).
The 'gc-protected-objects field reports the number of such objects
as (cons number-of-currently-protected-objects size-of-table).
((*s7* 'memory-usage) 'gc-protected-objects) will omit all the
other info.

More information about the Cmdist mailing list