MatFile grows exponentially larger in an empty table replacement loop?

1 回表示 (過去 30 日間)
埃博拉酱
埃博拉酱 2020 年 5 月 18 日
回答済み: Asvin Kumar 2020 年 5 月 20 日
First create a MatFile:
a=matfile("Test.mat");
Then create an empty table:
a.Data=table('Size',[0 1],'VariableTypes',"uint8");
The Test.mat is 23.3 ㎅. Now we run the code again to replace the table with the same new one:
a.Data=table('Size',[0 1],'VariableTypes',"uint8");
Note the file becomes 51.6 ㎅, about 2.2 times larger. Again, 91.6 ㎅, 1.8 times larger; 150 ㎅, 1.6 times larger; 223㎅, 1.5 times larger; 308㎅, 1.4 times larger; 407 ㎅, 1.3 times larger … What a horrible increase!

回答 (1 件)

Asvin Kumar
Asvin Kumar 2020 年 5 月 20 日
This is a known issue in MAT files saved with version 7.3 based on HDF5 which does not manage freespace as effectively as it should. Frequently rewriting or deleting a dataset can result in freespace and cause the file to grow unnecessarily large.
One workaround is to avoid changing a single variable in the matfile handle. Instead, load the variables and save it into a new MAT file. The other workaround is to choose the format 7.0 by using '-v7' argument of save. Please refer to the following section:
Some useful links containing the detailed explanation:

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by