Has save() bug been fixed?
Show older comments
I have a user-defined object that is failing to save in R2024b,
>> save testsave mgr
Warning: Variable 'mgr' was not saved. For variables larger than 2GB use MAT-file version 7.3 or later.
It is true that mgr is greater than 2GB. However, it belongs to a class with a saveobj() defined, which greatly compresses the size of the saved object. But the saveobj() method is never reached. The save() operation rejects the variable based on its original size, and never calls saveobj().
I think this has got to be a bug. Does anyone know if it has been fixed in more recent Matlab versions?
3 Comments
Stephen23
on 26 Jun 2026 at 14:55
"The save() operation rejects the variable based on its original size"
Which is exactly what the SAVE documentation refers to: the variable size.
"I think this has got to be a bug."
Why? The SAVE documentation clearly documents the limits of MAT files according to the variable size, not in terms of any (possibly compressed) resulting file size. It is odd to describe something working exactly as documented to be a "bug".
save defines the input variables as "Names of variables to save..." from which I think it's clear it's intended as applying to the existing object in memory.
That the support response reflects unintended behavior in prematurely exiting before calling a user-defined saveobj function with other than -v7.3 reinforces the conclusion I drew that it was simply an overlooked edge case that a custom function could perform compression behind SAVE's back.
ADDENDUM
Of course, the user-supplied function then will have to handle it's own case if it turns out compression also doesn't manage to get under the 2GB limit to write the variable out in -V7
Accepted Answer
More Answers (0)
Categories
Find more on Simulink Report Generator in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!