[Rcpp-devel] rsession memory consumption blows up

Dirk Eddelbuettel edd at debian.org
Wed Jun 24 22:05:24 CEST 2015


On 24 June 2015 at 20:31, Fabio Tordini wrote:
| Searching a little bit on the Internet I found a bug report on bugzilla 
| related to the issue I have.
| 
|  From this comment 
| https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14611#c3 on, Simon 
| Urbanek clarifies that all this has nothing to do with R. Rather, it is 
| about memory allocation in Linux, where it cannot release memory 
| allocated using brk if there are active blocks.
| It also states that the OS would swap out pages from the unused blocks. 
| I wonder why that didnt work out in may case, since R crashed soon after 
| re-launching the R function.
| 
| Anyway, I tried first what Hao suggested - free everything but the 
| objects to be returned - but it didnt change much: I could free about 
| 1GB of memory, but rsession kept holding more than 2GB, even after the 
| c++ function terminated.
| 
| After reading those comments in the bug report, I tried using the 
| malloc_trim() function (it forces the return of any unused memory space 
| to OS) from within R. This trick actually worked: rsession memory 
| consumption drops from 3.6GB to about 100MB, and R does not crash, even 
| after several subsequent calls to that "guilty" function.
| 
| I have a feeling this is a kind of dirty solution to a more serious 
| problem. But it does not seem to harm anything within my application.

i)  You still have not shown anything reproducible. This makes it hard for
us to help you.

ii) If you don't allocate the memory via R's alloc functions and free
diligently and do not return large objects to R, you should have no problem.

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list