Startup/Initialization Memory Leak in R
Luke Tierney
luke@stat.uiowa.edu
Thu, 12 Sep 2002 09:44:43 -0500 (CDT)
On Thu, 12 Sep 2002, David Bauer wrote:
>
> > > Is it already known that R does not free the memory that it allocates
> > >during start-up (~10MB) when it exits? If so, are there currently any
> > >plans to address this problem? I noticed that the 1.6.0 beta leaks
> > >slightly more memory (~300k) than the 1.5.1 stable version.
> >
> >I don't think this is known.
> >
> >What platform are you on, and how are you measuring the leak? On
> >Windows, it is not the responsibility of an application to release its
> >memory, that's the responsibility of the OS, so if the problem is
> >happening there, you should be talking to Microsoft (or questioning
> >how you measured it).
>
> Working on a Linux box, I originally found the leak using a memory
> management program that I wrote. I confirmed the leak using the Valgrind
> program (http://developer.kde.org/~sewardj/), which produces a nice
> output. If you would like, I can post a full or edited output from that
> program. The majority of the memory is allocated using the GetNewPage
> function in memory.c and appears to still be in the table of allocated
> pages when R exits.
>
I'm a little unclear on what you mean by "when R exits". R currently
does not have a mechanism for explicitly releasing all its heap
memory. That is fine when R is run as a process, the original design,
since the OS will release its memory when R exits (normally or
otherwise). When R is used as a shared library then there is no way
at this point to tell R that you are done with its heap and make sure
it is released. You can build a customized cleanup function and
install it so R_CleanUp calls it, but we currently don't provide a
hook for releasing the heap from that function. There are other
resources that we do not have convenient means of releasing explicitly
also, such as all loaded shared libraries. Being able to have
separate R sessions within a single process is something some of us
have talked about and that will require getting a handle on these
issues, but we're not there yet.
luke
--
Luke Tierney
University of Iowa Phone: 319-335-3386
Department of Statistics and Fax: 319-335-3017
Actuarial Science
241 Schaeffer Hall email: luke@stat.uiowa.edu
Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._