Workbook.dispose() method's use case

Hello,


I was going through the documentation of workbook.dispose() method. I could not get much details in the java docs for this method.

Can you provide some details regarding when to use workbook.dispose().

For example, consider the following sample code to convert chart to pdf:

private static void chartToPDF() throws Exception {
Workbook workbook = new Workbook(“test.xlsx”);
WorksheetCollection ws = workbook.getWorksheets();
Chart chart = workbook.getWorksheets().get(0).getCharts().get(“Chart 1”);
chart.toPdf(“D:\test.pdf”);
workbook.dispose();
}

Here I am creating a new Workbook object, extracting a chart and converting it to pdf. Do I need to always release resources using workbook.dispose() method when the Workbook object is no more needed.

Can you tell me in detail the specific scenarios in which this method should be used.

Hi,


Thanks for your query.

This is same in JAVA. Workbook.dispose() method performs tasks associated with freeing, releasing, or
resetting un-managed resources. Aspose.Cells for Java is created in pure JAVA, so you do not need to call this method as garbage collector actually does this for all unused objects (including Workbook) in regular intervals accordingly.

And, we have fixed your issue (in our latest version/fix v8.6.2) you mentioned in your other thread:
<a href="https://forum.aspose.com/t/37857

Thank you.