The java.lang.OutOfMemoryError: Java heap space exception when loading large XLSB files

Hi team,

Attached is a sample XLSB file (sample.7z (5.9 MB)
) and its file size is about 323MB. We have added MemorySetting.MEMORY_PREFERENCE to optimize the memory consumption, but we still encountered “java.lang.OutOfMemoryError: Java heap space” exception when loading this file. Could you please take a look at it.

OS is Ubuntu 20.04
The xms and xmx settings is -xms64M -xmx2250M
JDK version is OpenJDK 11.0.16
Following is the source code:

import com.aspose.cells.*;

public class Test {
public static void main(String[] args) {
try {
int loadFilterOptions = LoadDataFilterOptions.ALL & ~LoadDataFilterOptions.CHART &
~LoadDataFilterOptions.FORMULA & ~LoadDataFilterOptions.TABLE &
~LoadDataFilterOptions.PIVOT_TABLE;

        LoadOptions loadOptions = new LoadOptions();
        loadOptions.setLoadFilter(new LoadFilter(loadFilterOptions));
        loadOptions.setMemorySetting(MemorySetting.MEMORY_PREFERENCE);
        Workbook slbxWorkbook = new Workbook("sample.slxb", loadOptions);
    } catch (Exception e) {
        System.out.println(e.toString());
    }
}

}

@Rich_Yu,

Thanks for the sample XLSB file.

Please notice, I am able to reproduce the issue as you mentioned by using your template XLSB file. I found an exception “java.lang.OutOfMemoryError: Java heap space” when loading the large XLSB file. I have logged a ticket with an id “CELLSJAVA-44908” for your issue. We will look into it soon.

Once we have an update on it, we will let you know.

@Rich_Yu,

The main reason of the memory issue is that the cells dataset in your template file is too large. When viewing files in the archive(sample.xlsb), you will find that the file xl\worksheets\sheet1.bin is about 1.5G. That means even we build our cells data model in the similar way with compact structure(MEMORY_PREFERENCE), and take no other factors into account, we still need more than 1G memory for those cells data. In fact during the loading process, we also need much more extra memory for other data models, stream buffers, …etc.

By our test, to load this template file, the total memory required is about 3.5~4G.

One possible improvement for the memory we can do in future is to reduce the size of stream buffer for such large data set. We hope such kind of improvement may help to save about 600M-1G memory for the loading process for this specific template file. For other data models and processes, we are afraid we have no better solution to save more memory.

@Rich_Yu,

We are pleased to inform you that we have fixed your issue (logged earlier as “CELLSJAVA-44908”). We will provide you the hotfix in your paid support thread.

The issues you have found earlier (filed as CELLSJAVA-44908) have been fixed in this update. This message was posted using Bugs notification tool by Peyton.Xu