There are file File space management strategies that can be set to manage the unused space in a file. These are set with the were introduced via H5P_SET_FILE_SPACE_STRATEGY function to manage the unused space in a file.
While a file is open, HDF5 tracks and re-uses the unused space in the file according to the strategy used. If using a strategy that uses the free space manager, then free space can be tracked across file opens by use of the "persist" flag . Otherwise, and a minimum free space threshold can be specified. If not specifying a strategy that uses the free space manager, then when the file is closed, the any free space is lost and will remain in the file.
File space management only occurs between the HDF5 file open and close, and the free space is NOT tracked beyond file closed. In other words, when you delete a dataset, the space used by the dataset becomes free space that can be re-used as long as the file is open. Once the file is closed, the free space is lost and will remain in the file.