Hi Team,
We are currently testing the Aspose.Cells for Python via Java trial version API to unhide the content of an XLSX file. However, we are encountering a “java.lang.OutOfMemoryError: Java heap space” error in the following scenario.
FileSize = 42 MB
Total file of same size = 2
ThreadPool = 2
FileType = XLSX
MaxHeapSize = 1024MB (This is the maximum I am permitted to use.)
Aspose Cells Version = 24.4.0
Even when I attempt to process a single file with one thread, it still consumes an excessive amount of memory. Below are the JProfiler memory statistics. Could you please help me understand why it is using so much memory?
I have attached 40MB test file and the memory snapshot for your reference.
image.png (25.1 KB)
40MB-TestFile.zip (8.3 MB)
Below are my sample code:
from multiprocessing.dummy import Pool as ThreadPool
import multiprocessing
import time
import jpype
if jpype.isJVMStarted() == False:
classpath = “C:/Program Files/Amazon Corretto/”
jvmArgs = [“-Djava.class.path=” + classpath, “-Xmx1024M”]
jpype.startJVM(u"C:/Program Files/Amazon Corretto/jdk21.0.2_13/bin/server/jvm.dll", *jvmArgs)
overAllTime = time.time()
max_num_processes = multiprocessing.cpu_count()
print(“\nMAX number of processes=” + str(max_num_processes))
def flatten(x):
from asposecells.api import Workbook
source_directory = "Examples/SampleFiles/SourceDirectory/"
start = time.time()
fileName = "40MB-TestFile.xlsx"
workbook = Workbook(source_directory + fileName)
for ws in workbook.getWorksheets():
ws.getCells().unhideColumns(0, ws.getCells().getMaxDataColumn() + 1, -1)
ws.getCells().unhideRows(0, ws.getCells().getMaxRow() + 1, -1)
if ws.isVisible() == False:
ws.setVisible(True);
# Save the excel file.
newFileName = str(x)+"__" + fileName
workbook.save(source_directory + "flatten/" + newFileName)
flattenTime = (time.time() - start) * 1000
print('\nFlatten Time taken =================================**************************{:.2f} ms'.format(
flattenTime))
return x
a = [1,2]
pool = ThreadPool(2)
pool.map(flatten, a)
pool.close()
pool.join()
jpype.shutdownJVM()
duration = (time.time() - overAllTime) * 1000
print(‘\nTime taken {:.2f} ms’.format(duration))
Thanks,
Ashish