<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi,<div><br></div><div>I was trying RcppArmadillo sparse matrix and found an odd memory behavior.</div><div><br></div><div>I used this code from Romain <a href="http://stackoverflow.com/questions/18336021/sparse-matrix-conversion-from-matrix-to-armadillo-with-rcpparmadilloextensions-s">http://stackoverflow.com/questions/18336021/sparse-matrix-conversion-from-matrix-to-armadillo-with-rcpparmadilloextensions-s</a> </div><div>and added the first line to manage large matrices</div><div><br></div><div><div>#define ARMA_64BIT_WORD</div><div>#include <RcppArmadillo.h></div><div>// [[Rcpp::depends("RcppArmadillo")]]</div><div>using namespace Rcpp ;</div><div><br></div><div>// [[Rcpp::export]]</div><div>arma::sp_mat sparse( arma::sp_mat A ){</div><div> A(0,0) = 1;</div><div> A(1,0) = 2;</div><div> return A ;</div><div>}</div></div><div><br></div><div>then tested with this</div><div><br></div><div>library(Matrix)</div><div>testMatrix <- Matrix(data=0,nrow=1e7,ncol=1e7,sparse=TRUE) # 40MB sparse matrix</div><div></div><div>gc()</div><div>sparse(testMatrix)</div><div><div>gc()</div></div><div><br></div><div>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.</div><div><br></div><div>Am I doing something wrong?</div><div><br></div><div>For reference, I'm using Rcpp_0.10.6, RcppArmadillo_0.3.920.1, R 3.0.1 on a Mac OSX 10.7.5.</div><div><br></div><div>Thanks for the help!</div><div> Alessandro</div></body></html>