tests/testthat/test-gc.R

## rxodeTest(
##   {
##     options(RxODE.unload.unused = TRUE)
##     library(RxODE)
##     library(testthat)
##     context("Garbage collection")
##     test_that("Check garbage collection unloads DLLs", {
##       options(RxODE.unload.unused = TRUE)

##       ode <- RxODE({
##         b <- -1
##         d / dt(X) <- a * X + Y * Z
##         d / dt(Y) <- b * (Y - Z)
##         d / dt(Z) <- -X * Y + c * Y - Z
##       })

##       name <- basename(rxDll(ode))
##       name <- substr(name, 0, nchar(name) - nchar(.Platform$dynlib.ext))

##       expect_false(is.null(getLoadedDLLs()[[name]]))
##       Sys.sleep(0.5)
##       gc()
##       Sys.sleep(0.5)
##       expect_false(is.null(getLoadedDLLs()[[name]]))
##       rm(ode)
##       Sys.sleep(0.5)
##       gc()
##       Sys.sleep(0.5)
##       expect_true(is.null(getLoadedDLLs()[[name]]))

##       options(RxODE.unload.unused = FALSE)
##     })
##     options(RxODE.unload.unused = FALSE)
##   },
##   test = "lvl2"
## )
nlmixrdevelopment/RxODE documentation built on April 10, 2022, 5:36 a.m.