[Rcpp-devel] RcppArmadillo Memory Leak?

Alessandro Vitale alevitale at gmail.com
Mon Nov 18 15:59:27 CET 2013


Thanks Dirk and Hadley.

Dirk, asap I will try your b) and c) suggestions. While for suggestion a), I didn't really understand how to implement it.

Hadley, I am determining rsession process memory looking at osx activity monitor utility, under Real Mem column.
This is what I get (I am using your own mem() function to determine r memory usage)

testMatrix <- Matrix(data=0,nrow=1e7,ncol=1e7,sparse=TRUE)
gc()
mem() # [1] 123.3, rsession Real Mem 203.1 MB
sparse(testMatrix)
mem() # [1] 161.5
gc()
mem() # [1] 123.4, rsession Real Mem 507.8 MB
sparse(testMatrix)
mem() # [1] 161.5
gc()
mem() # [1] 123.4,  rsession Real Mem 585.0 MB
sparse(testMatrix)
mem() # [1] 161.5
gc()
mem() # [1] 123.4,  rsession Real Mem 661.3 MB

and so on.

If I call the function too many times (in fact I discovered it while using benchmark() ), it fills up the memory and the computer gets totally unresponsive.
 




On 18 Nov, 2013, at 15:24 , Hadley Wickham wrote:

>> After every call, the memory from gc() is stable, while rsession process
>> memory keeps growing of around 100Mb at each call and doesn't decrease after
>> the garbage collection.
> 
> You don't mention how you're determining the size of the rsession
> process, but you shouldn't necessarily expect it to decrease after
> calling gc() - there may be memory fragmentation, but also the OS is
> lazy about reclaiming memory from processes, so it may only be
> returned to the OS when it actually needs it.
> 
> Hadley
> 
> -- 
> Chief Scientist, RStudio
> http://had.co.nz/



More information about the Rcpp-devel mailing list