I am facing some errors with unit tests in our suite, because we don’t have a license configured for them. I do know there is a limit of 100 concurrent workbooks, but I expected to be to use “workbook.dispose()” and continue testing. This doesn’t work, as seen here:
@Test
void testOpenLotsOfWorkbooks() throws Exception {
for (int i = 0; i < 1000; i++) {
workbook = new Workbook(FILE.getAbsolutePath());
assertTrue(workbook != null);
System.out.println("Opened workbook " + (i + 1));
workbook.dispose();
workbook = null;
}
}
It seems you are encountering issues with releasing resources from workbooks in your unit tests, particularly when using the workbook.dispose() method. This method is designed to free unmanaged resources associated with the workbook, but there are a few considerations to keep in mind.
Dispose Method: Ensure that you are calling the Dispose method correctly. This method should effectively release the resources used by the workbook. You can also use a using statement to ensure that the workbook is disposed of properly when it goes out of scope. For example:
using (Workbook wb = new Workbook())
{
// Your code here
} // Workbook is disposed automatically here
Concurrent Workbook Limit: As you mentioned, there is a limit of 100 concurrent workbooks. If you exceed this limit, you may encounter errors. Make sure that all workbooks are being disposed of properly to avoid hitting this limit during your tests.
Testing Without License: If you are running tests without a configured license, be aware that this may also affect the behavior of the library. It is advisable to configure a license for your testing environment to avoid any limitations imposed by the evaluation version.
If you continue to experience issues after ensuring that you are disposing of the workbooks correctly, consider checking for any lingering references to the workbook objects that might prevent garbage collection.
For further reference, you can look at examples of managing workbook resources in both C# and Java, which demonstrate the proper use of the Dispose method.
If you have any specific error messages or additional details, feel free to share them for more targeted assistance.
I think what you’re encountering is expected behavior when using Aspose.Cells for Java without a valid license. Please note, when you use Aspose.Cells for Java without setting a license in code, the following significant evaluation limitations apply:
A watermark is added to the output files (if generated).
Only 100 workbooks can be opened concurrently in one process.
Even if you call Workbook.dispose(), it may not free the internal evaluation counter, because that limitation is not based on memory usage or GC, but on internal static licensing checks we included.
We recommend if you want to test Aspose.Cells without evaluation version limitations or other restrictions, you should request a 30-day temporary license and get it. Please refer to How to get a Temporary License? for more information. After getting the license, please don’t forget to set the license in code at the start and prior using Aspose.Cells for Java APIs, see the document Licensing|Documentation for your reference.
Perfect, I just wanted to confirm if dispose should allow more than 100 files to be opened even with the evaluation version. I’ll look at applying the license correctly