An object (dataset, group, attribute, named datatype) in an HDF5 file can be opened, and it can be opened more than once. When an object is opened, the HDF5 library returns a unique identifier to the application. Every object that is opened must be closed. If an object was opened more than once, each identifier that was returned to the application must be closed. For example, if a dataset was opened twice, both dataset identifiers must be released (closed) before the dataset can be considered closed. Suppose an application has opened a file, a group in the file, and two datasets in the group. In order for the file to be totally closed, the file, group, and datasets must each be closed. Closing the file before the group or the datasets will not effect the state of the group or datasets: the group and datasets will still be open.

There are several exceptions to the above general rule: