释放工作簿的非托管资源
Contents
[
Hide
]
Aspose.Cells提供Workbook.dispose()方法来释放Workbook对象的非托管资源。Dispose模式仅适用于访问非托管资源的对象,例如文件和管道句柄、注册表句柄、等待句柄或指向非托管内存块的指针。这是因为垃圾收集器在回收未使用的托管对象方面非常有效,但无法回收非托管对象。
释放工作簿的非托管资源
以下示例代码演示了如何使用Workbook.dispose()方法。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ReleaseUnmanagedResources.class); | |
// Create workbook object | |
Workbook wb1 = new Workbook(); | |
/* | |
* Call dispose method,It performs application-defined tasks associated with freeing, releasing, or resetting | |
* unmanaged resources. | |
*/ | |
wb1.dispose(); | |