[R] dyn.load, dyn.unload -memory management

From: johan Faux <johanfaux_at_yahoo.com>
Date: Sat 29 Jul 2006 - 08:04:56 EST


hello everybody,

I have some code which looks like:

dyn.load("lpSolve.so")
res <- lp(some.parameters)

and everything runs fine.

What lp() does, it's just calling a C function which is in "lpSolve.so"

If I call lp() a large number of times:

for(1 in 1:5000){
gc(verbose=TRUE)
res <- lp(some.parameters)
}

then gc() is showing that the memory used by R process remain almost constant all the time. But the system memory used is going up _very fast_ and the above code never succeed because the memory used rich the limit.
>From this I'm drawing the conclusion that there is some memory leak on the C code called by lp() which gc() cannot report since this is a C process.

Does all this makes any sense or I'm wrong?

The next thing I tried was

for(1 in 1:5000){
 gc(verbose=TRUE)
dyn.load("lpSolve.so")
 res <- lp(some.parameters)
dyn.unload("lpSolve.so")
 }
 

But the problem is still there. The memory used is going up really fast. Now my other question is: When I call dyn.unload() doesnt it terminate the previous C process? Next time in the loop, a new C process starts, and I will not have any problem with memory.

Any comment is very much appreciated,
Thank you ,
Johan

P.S. lpSolve.so above is from package "lpSolve". I thought that getting "lpSolve.so" and doing the above trick will solve my problem, but I have been surely wrong.                          



See the all-new, redesigned Yahoo.com. Check it out.

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat Jul 29 08:09:05 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 29 Jul 2006 - 12:16:38 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.