java.lang.OutOfMemoryError: Java heap space when upgrading Aspose cells from 25.1 to 25.6

Environment Details:

Aspose.Cells Version: 25.2 to 25.6
Jenkins OS: Linux
Java Version: OpenJDK 17

Problem Description:

I am using Aspose.CELLS to convert cells to HTML and getting OutOfMemory error. Here is the error message “java.lang.OutOfMemoryError: Java heap space”.

Code works fine with Aspose 25.1, but when try to upgrade from 25.1 to any version > 25.1(25.2, 25.6), it starts giving this error.

I’ve attached sample code with test file. Entry point of the code would be AsposeCells.run() method. Error is coming from AsposeCellsToHtmlUtils.documentToHtml

Kindly help with this issue.

Aspose_Cells_Sample_Code.zip (1.7 MB)

@sthadhani

Cause

The java.lang.OutOfMemoryError: Java heap space error typically occurs when the Java Virtual Machine (JVM) runs out of memory while trying to allocate space for objects. In your case, this issue arises after upgrading Aspose.Cells from version 25.1 to 25.6, which may have introduced changes that require more memory for processing.

Solution

To address this issue, you can try the following steps:

  1. Increase JVM Heap Size: Adjust the heap size allocated to the JVM. You can do this by modifying the -Xmx parameter in your Java options. For example, to set the maximum heap size to 2GB, you can use:

    -Xmx2g
    
  2. Use Memory Preferences: Aspose.Cells provides memory settings that can help optimize memory usage when loading large spreadsheets. You can specify memory preferences in your code as follows:

    LoadOptions options = new LoadOptions();
    options.setMemorySetting(MemorySetting.MEMORY_PREFERENCE);
    Workbook workbook = new Workbook("yourfile.xlsx", options);
    
  3. Optimize Data Handling: If your Excel files are particularly large, consider optimizing how you handle data. For instance, process data in smaller chunks or reduce the complexity of the operations performed.

Code

Here’s a minimal code snippet to illustrate how to implement the memory preferences:

import com.aspose.cells.*;

public class AsposeCellsExample {
    public static void main(String[] args) {
        try {
            LoadOptions options = new LoadOptions();
            options.setMemorySetting(MemorySetting.MEMORY_PREFERENCE);
            Workbook workbook = new Workbook("yourfile.xlsx", options);
            // Your code to convert to HTML or other operations
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Next Steps

  1. Increase the heap size and test your application again.
  2. Implement the memory preferences in your code.
  3. If the issue persists, consider profiling your application to identify memory usage patterns and optimize accordingly.

Please proceed with these steps and let me know if you need further assistance!

@sthadhani,

Thanks for the sample file, details and code snippet.

We need to conduct a detailed investigation of your issue across both older and newer versions within the underlying Linux environment. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSJAVA-46432

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Sure, Thanks

@sthadhani,

We will keep you posted with updates (once available) on it.

1 Like

@sthadhani ,

We are pleased to inform you that your issue has been resolved. The fix will be included in an upcoming release (Aspose.Cells v25.8) that we plan to release in the first half of August 2025. You will be notified when the next version is released.
Here is the result after the fix for your reference:
output.zip (909.2 KB)

okay, thanks

@sthadhani,

You are welcome. The upcoming version is expected to be released between August 10th and 15th, 2025. We’ll make sure to keep you updated as soon as it becomes available.

1 Like