[plt-scheme] Memory management and MzScheme
I wrote:
> The obvious possibly problematic difference between your two examples is
> that one is using scheme_malloc and the other is not. I haven't actually
> done any extension work with MzScheme specifically, but I'd guess
> that this could lead to trouble.
I should have added that the "obvious" problem I mentioned is that
scheme_malloc is for allocating memory that contains pointers to collectable
objects. If you *don't* use it, as in the std::vector case using the
default STL allocator, then you're allocating Scheme objects with
scheme_make_string, but the only place their pointers are being stored is in
memory that hasn't been "registered" with MzScheme's garbage collector. I
_assume_ that this will mean that when garbage collection takes place, it's
going to think that all the strings you've created are no longer referenced,
and start collecting them - at which point your program will start having
problems.
Anton