hdf5_close_all: Close all HDF5Matrix objects

View source: R/hdf5CloseAll.R

hdf5_close_allR Documentation

Close all HDF5Matrix objects

Description

Finds and closes all HDF5Matrix objects in the specified environment.

Usage

hdf5_close_all(envir = .GlobalEnv, verbose = TRUE)

Arguments

envir

Environment to search (default: .GlobalEnv)

verbose

Show details (default: TRUE)

Details

This function:

  • Searches for HDF5Matrix objects in the environment

  • Calls $close() on each valid object

  • Forces garbage collection

  • Reports closed files

Note: Only finds objects in the specified environment. Objects inside functions or other environments are not affected.

Value

Invisible vector of closed filenames

Examples


tmp1 <- tempfile(fileext = ".h5")
tmp2 <- tempfile(fileext = ".h5")

X  <- hdf5_create_matrix(tmp1, "data/A", data = matrix(rnorm(100), 10, 10))
Y  <- hdf5_create_matrix(tmp2, "data/B", data = matrix(rnorm(100), 10, 10))

X <- hdf5_matrix(tmp1, "data/A")
Y <- hdf5_matrix(tmp2, "data/B")

# Both open
X$is_valid()  # TRUE
Y$is_valid()  # TRUE

# Close all at once
hdf5_close_all()

# Both closed
X$is_valid()  # FALSE
Y$is_valid()  # FALSE

# Cleanup
unlink(c(tmp1, tmp2))



BigDataStatMeth documentation built on May 15, 2026, 1:07 a.m.