asammdf icon indicating copy to clipboard operation
asammdf copied to clipboard

Memory allocation error when resampling a file

Open fhaon opened this issue 1 month ago • 1 comments

I have a file whose data was sampled with a 1 µs period over a long duration. The file is more than 60 GB. When I try to resample the file using the asammdf GUI application, I get the following error:

File "C:\Users\haonf\Documents\Dev\asammdf\Python\Lib\site-packages\asammdf\mdf.py", line 4147, in select return self._select_fallback( ~~~~~~~~~~~~~~~~~~~~~^ channels, record_offset, raw, copy_master, ignore_value2text_conversions, record_count, validate ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "C:\Users\haonf\Documents\Dev\asammdf\Python\Lib\site-packages\asammdf\mdf.py", line 4483, in _select_fallback master = np.empty(cycles, dtype=sigs[0].timestamps.dtype) numpy._core._exceptions._ArrayMemoryError: Unable to allocate 29.4 GiB for an array with shape (3947209972,) and data type float64

It looks like the entire time vector is being allocated in RAM. Is this a limitation of the library, or is there an option to avoid allocating everything in RAM (e.g., block-wise resampling) ?

python 3.12 assamdf 8.7.2 numpy 2.3.5

fhaon avatar Nov 21 '25 15:11 fhaon

You can try per channel chunked access using iter_get https://asammdf.readthedocs.io/en/latest/api.html#asammdf.mdf.MDF.iter_get

danielhrisca avatar Nov 21 '25 15:11 danielhrisca