Memory model in building xlsx

Hi,


Cell API works in memory and finally save to file in command:

com.aspose.cells.Workbook myWorkbook = create…
FileOutputStream myFileOutputStream = create…

myWorkbook.save(myFileOutputStream, SaveFormat.XLSX);

During the workbook creation it keeps all objects within workbook in memory. Is there any way to flash the to disk during the creation before final save and release memory?

Regards,

Hi,


Thanks for your query.

There is no such option available to physically store all objects’ data to disk. I think you may try to use Workbook.dispose() method to perform application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. Also, in newer versions, you can set memory preference options to minimize the memory usage, see the document for your reference:

Thank you.

Is there any technical notes what exactly is reduces in memory when using MEMORY_PREFERNCE? How often is flushes to disk when used?

Hi,

Thanks for your posting and using Aspose.Cells.

MemoryPreference mode does not flush objects to disk either. When saving in this mode, we use binary data in memory instead of cell related objects to reduce the memory cost. Whether using this mode can improve the performance depends on the cells data in the workbook. When there are lots of empty cells or cells with primary data such as bool, error, numeric values, this mode may give much better result comparing to Normal mode.