R (3.3.2, Windows 7) crashes after about 1000 iterations of dyn.load()
being used in a for loop. This does not happen in Ubuntu. This behaviour is observed for dll
files created from Rcpp
and TMB
code, but I don't think it is related to either of these packages. The crash message is:
Problem Event Name: APPCRASH
Application Name: rsession.exe
Application Version: 1.0.136.0
Application Timestamp: 583f5668
Fault Module Name: testRcppRepeatDynLoad.dll
The following is a mimimal reproducible example on my computer:
First, create an Rcpp
package called testRcppRepeatDynLoad
(in Rstudio, create package in new directory, select 'create package with Rcpp'.). Building the package with CTRL-SHIFT-B
creates a dll
file in the src
folder, which we will load using dyn.load
.
This code crashes the R session after 1050 iterations:
while (i < 2000) {
i = i + 1
print(i)
dyn.load('src/testRcppRepeatDynLoad.dll')
dyn.unload('src/testRcppRepeatDynLoad.dll')
}
The same thing happens for a dll
file created by TMB::compile
.