Welcome to MicroAPL's Support Forum for APLX.

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, join our community today!

java.lang.OutOfMemoryError: Java heap space

How to interface APL to Java

java.lang.OutOfMemoryError: Java heap space

Postby dcoudry » Wed Nov 09, 2011 9:55 pm

I use POI Apache Java libraries to read and write Excel files. I need to produce very large Excel files: some 20000 lines and around 40 columns.

The POI Apache Excel functions write the whole file in memory (somewhere) before writing it to the file. After around 12000 lines produced, I get a java.lang.OutOfMemoryError: Java heap space.

Even if I cut down my program to write 1000 lines at a time (open the Excel file, write data, close the file), I still get the same error after writing around 120000 lines.

I tried the 'java' []SETUP 'vmoptions' using different combinations of Xms and Xmx and the results were the same. I quit APLX before each try.

Any hints ?

Posts: 3
Joined: Fri Sep 12, 2008 7:53 pm

Re: java.lang.OutOfMemoryError: Java heap space

Postby MicroAPL » Thu Nov 17, 2011 12:12 pm

What options to Xms and Xmx did you try? You need something like:

     'java' ⎕setup 'vmoptions' 'Xmx=512m'

One hint to assist your investigations: you can get information about the state of memory usage as follows:

      rt←'java' ⎕new 'java.lang.Runtime'

Also, have you looked at the information about the error, available from ⎕LE?
Site Admin
Posts: 335
Joined: Tue Jul 08, 2008 5:25 pm

Re: java.lang.OutOfMemoryError: Java heap space

Postby dcoudry » Thu Feb 09, 2012 9:37 pm

Sorry for the late answer, I was switched to something else.

I have tried several values for the vmoptions, like "Xms512m Xmx2048m", high values, low values, and the memories returned by java.lang.Runtime always gave me max: 99M, total: 65M and free: 65M.

I tried "hello" as vmoptions and it does not return an error. So, what is the proper syntax for the vmoptions ? Does it really work ?

Posts: 3
Joined: Fri Sep 12, 2008 7:53 pm

Return to Interfacing to Java