0

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.

1

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

15 Comments

Thanks for the reply.
Thanks for the reply,
Thanks for the reply. I opened up command prompt and typed the code you suggested: java -Xmx2g MyApplication.bat. It did not seem to work. Am I doing something wrong?
Since it is a .bat file the java command is probably inside the .bat file. Have a look in the file and there should be a command starting with java. There you can add the parameter.
I opened up the .bat file and entered following code:
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.