Not releasing untouched sector data.
Structured Storage .net component - pure C#
Brought to you by:
ironfede
In CompoundFile.Commit(bool) during releaseMemory mode non dirty existent sectors are not cleaned up.
Current setup:
if (s != null && s.DirtyFlag)
{
...
commit to file
...
}
else
{
gap = true;
continue;
}
if (releaseMemory)
{
s.ReleaseData();
s = null;
sectors[i] = null;
}
If a sector exists and is not dirty the continue in the else will prevent the release of the untouched memory even though the transaction is completed.
Suggestion:
if (s != null && s.DirtyFlag)
{
...
commit to file
...
}
else
{
gap = true;
}
if (releaseMemory && s != null)
{
s.ReleaseData();
s = null;
sectors[i] = null;
}
Also possibly implement a method to release memory without touching the file (for memory management during CFSUpdateMode.ReadOnly).
Unit tests all pass with these changes.
Thank you very much. Committed to dev.