This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [Q] automagic define/undefine with dynamic-link/dynamic-unlink


Ole Myren R|hne <mrohne@mixing.uio.no> writes:
>
> Marius Vollmer writes:
>  > Ole Myren R|hne <mrohne@mixing.uio.no> writes:
>  > > Question: guile seems to leak memory each time the test is repeated. I
>  > > am looking for some `gh_delete_procedure' that guarantees that all
>  > > resources allocated by gh_new_procedure are released.
>  > 
>  > Hmm, how much memory does it leak?
> 
> I am not shure, as I don't really know how to prove or measure a
> memory leak with guile. I watch guile's size in memory increase as I
> cycle (dynamic-unlink (dynamic-link "./mysin.so")). It grows about 16
> bytes per cycle and is never reclaimed with (gc)

How do you watch the memroy size?  With "top"?  Top usually displays
the size of a process in multiples of 1K, I think.  And anyway
externally visible memory grow should come in larger blobs than 16
bytes I think.

Anyway, I can reproduce your problem.  Watching Guile with top, while
executing

    (let loop () (dynamic-unlink (dynamic-link "./mysin.so")) (gc) (loop))

gave a constant memory usage increase.

I wrote this little test program in C to check this:

    #include <dlfcn.h>

    int
    main ()
    {
      void *handle;

      while (handle = dlopen ("./so.so", RTLD_LAZY))
	dlclose (handle);

      return 0;
    }

with this trivial shared library

    void f()
    {
    }

This, too, exhibits a memory leak.  It runs for six minutes now and
has grown from about 1M to 12M.

So i think the problem is with the dlopen implementation.