Reputation: 614
I am writing an R package using RcppEigen called RcppCoDA
I think there may be a memory leak somewhere in my project but I am not sure. I am unfortunately having trouble running Valgrind as it seems it may not support the OS X Mojave and I am running into errors detailed here.
I think it should be pretty easy to reproduce the error:
library(RcppCoDA) # devtools::install_github("jsilve24/RcppCoDA")
library(microbenchmark)
d <- c(100,1000)
X <- matrix(abs(rnorm(prod(d))), d[1], d[2])
X <- clo(X)
# This runs fine
z <- RcppCoDA::alr(X, d=4)
# This for some reason takes forever to run... I think this might be a bug
for (i in 1:1000){
z <- RcppCoDA::alr(X, d=4)
}
# This causes RStudio to crash... or takes forever to run...
microbenchmark(
RcppCoDA::alr(X, d=4), times=10
)
I have reread the code over and over and don't see how I could be having memory errors unless I am just misusing Rcpp somehow... Unfortunately, as I can't seem to get Valgrind to work as outlined here I am really at a loss for how to debug. I am not even sure if there is a bug in my code or somewhere else.
Any help would be most appreciated!
Upvotes: 2
Views: 355
Reputation: 614
Thanks to some helpful comments I was able to get Valgrind working in a docker image.
Just an outline of how I did it:
docker run rocker/rstudio
docker ps
docker exec -it <containerID> bash
R -d "valgrind --leak-check=full"
Thank you for the help!
Upvotes: 3