Dear R community, I was observing a memory issue in R (latest 64bit R version running on a win 7 64 bit system) that made me curious. I kept track of the memory f my PC allocated to R to calculate + keep several objects in the workspace. If I then save the workspace, close R, and open the workspace again, less memory is allocated to keep the same set of variables into the workspace. For my case, the reduction in memory size was quite significant (approx. 2 GB). Does anyone know why R behaves in this manner - put differently: What does R keep in the workspace beyond the objects before I close R? Can I induce the reduction in memory without the need to close R? Thanks for an email! Marc
You may want to enable garbage collection on gctorture(on = TRUE) see: ?gctorture ?gcinfo ?object.size>-----Original Message----- >From: r-help-bounces at r-project.org[mailto:r-help-bounces at r-project.org]>On Behalf Of Marc Jekel >Sent: 23 November 2011 15:42 >To: R-help at r-project.org >Subject: [R] memory allocation in R > >Dear R community, > >I was observing a memory issue in R (latest 64bit R version running ona>win 7 64 bit system) that made me curious. > >I kept track of the memory f my PC allocated to R to calculate + keep >several objects in the workspace. If I then save the workspace, closeR,>and open the workspace again, less memory is allocated to keep the same >set of variables into the workspace. For my case, the reduction in >memory size was quite significant (approx. 2 GB). > >Does anyone know why R behaves in this manner - put differently: What >does R keep in the workspace beyond the objects before I close R? Can I >induce the reduction in memory without the need to close R? > >Thanks for an email! > >Marc > >______________________________________________ >R-help at r-project.org 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.LEGAL NOTICE This message is intended for the use o...{{dropped:10}}
On Nov 23, 2011, at 10:42 AM, Marc Jekel wrote:> Dear R community, > > I was observing a memory issue in R (latest 64bit R version running on a win 7 64 bit system) that made me curious. > > I kept track of the memory f my PC allocated to R to calculate + keep several objects in the workspace. If I then save the workspace, close R, and open the workspace again, less memory is allocated to keep the same set of variables into the workspace. For my case, the reduction in memory size was quite significant (approx. 2 GB). > > Does anyone know why R behaves in this manner - put differently: What does R keep in the workspace beyond the objects before I close R? Can I induce the reduction in memory without the need to close R? >You can explicitly clean up using gc() [do not use gctorture() - that is nonsensical this context]. After that R keeps in memory only objects that are currently in use. What is in the workspace (global environment) is explicitly under your control. Note, however, that the system (reported by tools like ps or top) may not be able to reclaim memory (in particular Linux) even though R has released it - see R FAQ 7.42 for details. Cheers, Simon> Thanks for an email! > > Marc > > ______________________________________________ > R-help at r-project.org 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. > >