DYN.UNLOAD: Unload DLL easily

DYN.UNLOADR Documentation

Unload DLL easily

Description

R's dyn.unload is ridiculously hard to use in practice, because it requires complete paths. These can be extracted from getLoadedDLLs, but only with ridiculous amounts of effort and tricks that I always forget. Use DYN.UNLOAD instead with just the basename of the DLL(s) you actually want to unload.

Note that there can be multiple versions of a DLL loaded at the same time, with the same "name" (according to getLoadedDLLs) but different paths. This will unload the first one (only), so you may need to call it repeatedly.

Usage

DYN.UNLOAD( dllnames, warn_if_not_loaded=TRUE)

Arguments

dllnames

Usually one string, eg "my_dodgy_C_code", but you can do several at once (in a character vector, obvs).

warn_if_not_loaded

Pretty self-explanatory.

Value

The satisfaction of actually having cleared the bloody thing out of memory, eg so that you can delete the file.

Examples

## Not run: 
if( FALSE && is_very_annoying( CRAN)){ # otherwise CMD CHECK --as-cran tries to run this :/
  DYN.UNLOAD( "offending_C_code")
} # if F

## End(Not run)

mvbutils documentation built on May 25, 2026, 5:09 p.m.