Dispose method call needed in JAVA?

Do we need to explicitly call dispose method post save once everything with the workbook is done?

Is this applicable for all Excel, PDF, Doc, and PPT formats?

What if there are other operations happening on the workbook post the save method is called?

Similar to the topic (Dispose method call needed post the save of the workbook?), this seems to have gone under the .net family, but my question is more from the JAVA side. Also, if by any chance, save method isn’t called up, would that lead to memory leakage?

@lyash,

Similar is the case with Aspose.Cells for Java which does not necessarily require to free up the resources for the processes as the component is already optimized to do so automatically. Aspose.Cells for Java is created in pure Java, so when objects are no more useful, Garbage collection in Java (the automated process) takes up the charge to automatically free up memory space although you can also try to call Workbook.dispose() and set Workbook to null.

Regarding other APIs, e.g., Aspose.Words for Java, Aspose.PDF for Java and Aspose.Slides for Java, respective teams will assist you soon here.

1 Like

@lyash,
As for Aspose.Slides for Java, there are classes that implement the IDisposable interface (the Presentation class, for example), and you have to call the dispose() method after the class instance is not needed.

var presentation = new Presentation();
presentation.save("new_presentation.pptx", SaveFormat.Pptx);
presentation.dispose();

API Reference: Aspose.Slides for Java

1 Like

@lyash There is no need to dispose Aspose.Words.Document object. Aspose.Words for Java is pure managed code and when Aspose.Words object is out of scope, the Garbage Collector collects it.

1 Like