“./test 1000 1000 10000” works fine. However, it’s not representative since the C++ objects in this test do not hold ‘SCM’ references, AFAICS. > LilyPond's GUILEv2 branch is currently out of order again since 2.0.11 > changed encoding mechanisms _again_ Please submit a different bug report. >>> A pointer to a C++ structure does not appear to protect the >>> corresponding SMOB data and free_smob calls the delete operator which >>> calls destructors and clobbers the memory area. >> >> Oh, I was mistaken in my previous message. GC scans the stack and the >> GC-managed heap (stuff allocated with GC_MALLOC/scm_gc_malloc et al.), >> but it does *not* scan the malloc/new heap. >> >> So indeed, C++ objects that hold references to ‘SCM’ objects, such as >> instances of ‘Smob’, must either have a mark function, or they must >> be allocated with scm_gc_malloc. >> >> Would it be possible to add a ‘new’ operator to ‘Smob’ that uses >> ‘scm_gc_malloc’, and a ‘delete’ operator that uses ‘scm_gc_free’? > > It would not help since many of the references are stored in STL > containers (like std::vector ) which have their data > allocated/deallocated separately from the memory area of the structure > itself. Oh, OK. Still, I don’t think this is a problem because each C++ object has a corresponding SMOB, and said SMOB is GC-protected; thus the C++ object itself is also GC-protected until the SMOB is unprotected. Here’s the patch I’ve ended up with: