user28664
user28664

Reputation: 3

Application with java.lang.OutOfMemoryError: Java heap space

Recently, I started using a Java application a former colleague of mine designed. After performing certain actions, the application freezes and the error.log file shows the following:

Exception in thread "Thread-4" java.lang.OutOfMemoryError: Java heap space
    at org.apache.poi.poifs.storage.BATBlock.<init>(BATBlock.java:57)
    at org.apache.poi.poifs.storage.BATBlock.<init>(BATBlock.java:210)
    at org.apache.poi.poifs.storage.BATBlock.createBATBlocks(BATBlock.java:87)
    at org.apache.poi.poifs.storage.BlockAllocationTableWriter.simpleCreateBlocks(BlockAllocationTableWriter.java:150)
    at org.apache.poi.poifs.storage.BlockAllocationTableWriter.createBlocks(BlockAllocationTableWriter.java:103)
    at org.apache.poi.poifs.filesystem.POIFSFileSystem.writeFilesystem(POIFSFileSystem.java:221)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:744)
    at net.ndmystko.qa.QAJobReporter.writeWorkbook(QAJobReporter.java:478)
    at net.ndmystko.qa.QAJobReporter.writeResults(QAJobReporter.java:458)
    at net.ndmystko.qa.QAJobReporter.writeResults(QAJobReporter.java:402)
    at net.ndmystko.qa.QA.displayEvolutionProgress(QA.java:1257)
    at net.ndmystko.qa.QA.access$9(QA.java:1186)
    at net.ndmystko.qa.QA$4.actionPerformed(QA.java:1176)
    at net.ndmystko.analysis.evolution.Evolution.run(Evolution.java:191)

I have read that I would need to increase the heap size allotted to the application. However, I do not know how to achieve this, or where I could enter the code needed. Any help would be greatly appreciated.

Note: I am not experienced in programming. I run the program from a .bat file.

Upvotes: 0

Views: 1822

Answers (1)

dudel
dudel

Reputation: 692

You can use the following Java commandline parameters

-Xms: initial heap size
-Xmx: Maximum heap size

Set it when you run your application, e.g.

java -Xmx1024m YourClass

for allocating 1024 MB

java -Xmx2g YourClass

for allocating 2 GB

Edit: In regard to your note the java command is probably inside the .bat file. So you should open it up, find the java command and add the commandline arguments there.

Upvotes: 3

Related Questions