释放工作簿的非托管资源
Contents
[
Hide
]
Aspose.Cells 提供 Workbook.dispose() 方法,用于释放 Workbook 对象的非托管资源。dispose 模式仅用于访问非托管资源(如文件句柄、管道句柄、注册表句柄、等待句柄或非托管内存块指针)的对象。这是因为垃圾回收器在回收未使用的托管对象方面非常高效,但无法回收非托管对象。
释放工作簿的非托管资源
以下示例代码展示了如何使用 Workbook.dispose() 方法。
This file contains hidden or 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(); | |