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


Marius Vollmer writes:
 > 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.

I did:

(do ((i 0 (+ i 1))) 
    ((= i 102400)) 
  (dynamic-unlink (dynamic-link "./mysin.so")))

and divided the resulting increase by 100K (Surprise;-). But is a bit
more complicated because I have to be shure that a garbage collection
takes place. Funny, just writing (gc) doesn't seem to be enough...

 > I wrote this little test program in C to check this:
 > 
 > (deleted C implementation of infinite dlopen/dlclose loop)
 > 
 > This, too, exhibits a memory leak.  It runs for six minutes now and
 > has grown from about 1M to 12M.

Fine! If you replace your infinite loop by a finite loop, you'd be
able to report to the libdl implementors how much memory each
invocation leaks;-) And you could also check whether dlopen/dlclose
alone is responsible for all the memory leak seen with
dynamic-link/dynamic-unlink

I am still curious wheter some gh_delete_procedure is needed, or if
gh_eval_str("(undefine mysin)") does the trick?

Ole