[CM] Freeing up s7 instances & memory

Christos Vagias chris.actondev at gmail.com
Mon Sep 7 15:10:44 PDT 2020


Hi all and happy "new academic year",

I stumbled upon a case where I need to create multiple short lived s7
instances
(per thread). And I'm seeing the memory consumption getting higher and
higher
in my application.

What happens when we call "free(s7)" (s7 = s7_init) ?
>From what I'm seeing.. nothing

Consider this snippet, when in every loop I'm creating a c-object pointing
to a ~100mb char array.

    for (int i = 0; i < 10; i++) {
        s7_scheme *sc = s7_init();
        aod::s7::bind_all(sc); // binds the aod.c.foreign
        s7_eval_c_string(sc,
                         "(define x ((aod.c.foreign 'new-char[])
100000000))" // ~100 mb
                        );

        free(sc);
    }

That memory doesn't get freed. After all the iteration the memory usage
will be ~1GB.
I think at some point I stumbled upon a comment in the s7 source code that
was saying
something about this (could me mistaken though)

Thanks,
Christos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20200908/871f013d/attachment.html>


More information about the Cmdist mailing list