-
Notifications
You must be signed in to change notification settings - Fork 16
Closed
Description
TrxFile.close() seems to silently skips mmap cleanup for uncompressed .trx files.
I catched that when working on dipy/dipy#3808
here is a basic example
import tempfile
import os
import numpy as np
import trx.trx_file_memmap as tmm
trx = tmm.TrxFile(nb_streamlines=2, nb_vertices=6)
trx.streamlines._data[:] = np.random.rand(6, 3).astype(np.float32)
trx.streamlines._offsets[:] = np.array([0, 3], dtype=np.uint32)
trx.streamlines._lengths[:] = np.array([3, 3], dtype=np.uint32)
with tempfile.TemporaryDirectory() as tmp:
trx_path = os.path.join(tmp, "test.trx")
tmm.save(trx, trx_path)
trx.close()
loaded = tmm.load(trx_path)
print("_uncompressed_folder_handle:", loaded._uncompressed_folder_handle)
# we have None here <-- bug: should be a TemporaryDirectory handle
# close() silently skips ALL mmap cleanup.
loaded.close()
print("streamlines._data type:", type(loaded.streamlines._data))
# After close(), _data should be gone — but close() only called __init__()
# without first releasing the np.memmap handles.
# so on windows, file is locked, on linux, mmap is never released so leakI will dig a bit more to see if it was on purpose and there is something that I am doing wrong.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels