[R] Maximum # of DLLs reached, or, how to clean up after yourself?

Alexander Shenkin ashenkin at ufl.edu
Tue Sep 13 15:05:43 CEST 2016

Hello all,

I have a number of analyses that call bunches of sub-scripts, and in the 
end, I get the "maximal number of DLLs reached" error.  This has been 
asked before (e.g. 
and the general answer is, "just clean up after yourself".

Assuming there are no plans to raise this 100-DLL limit in the near 
future, my question becomes, what is best practice for cleaning up 
(detaching) loaded packages in scripts, when those scripts are sometimes 
called from other scripts?  One can detach all packages at the end of a 
script that were loaded at the beginning of the script.  However, if a 
package is required in a calling script, one should really make sure it 
hadn't been loaded prior to sub-script invocation before detaching it.

I could write a custom function that pushes and pops package names from 
a global list, in order to keep track, but maybe there's a better way 
out there...

Thanks for any thoughts.


More information about the R-help mailing list