Skip to main content

MTOM DataHandler OutOfMemoryError

2 replies [Last post]
Joined: 2009-09-21

I have a signed applet that connects to a WCF service that uses MTOM and streaming to move files. I can upload and download small files just fine, but when I try to move a larger file (ex. 40mb) I get an OutOfMemoryError; the stack trace is:

java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Unknown Source)
at Source)
at Source)
at javax.activation.DataHandler.writeTo(Unknown Source)
at$ByteArrayBuffer.write(Unknown Source)
at Source)
at Source)


I can increase the maximum heap size for my runtime and it works just fine, but this isn't really an acceptible option. I had thought that the DataHandler would not buffer the file before transmitting it, but it appears in the trace that it's writing to a ByteArrayOutputStream. Is it not possible to get the DataHandler to stream the bytes without buffering first? Perhaps I'm missing the boat on something, so any help would be greatly appreciated. I'm using jdk 1.6.0_16 and Netbeans 6.7.1 with the JAX-RPC Web Services plugin.


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2007-01-31

I have a similar issue with a datahandler. The only way I managed to get it to work is a little strange. Condition: Run the application withing Netbeans (run, debug, or analyzer) and be sure to include an additional library... axis-ant.jar!! I can upload gigabytes in this environment and only use ~10MB of memory at peak!... I can't figure out how to get it to run outside of Netbeans....

Let me know if you ever found or find a solution....

Joined: 2011-04-08

Hi! I'm experiencing the same issue. The error even occurs when I use the writeTo(OutputStream) method and with the getInputStream() - and reading the contents in blocks of 4KB.
Have you - or somebody - found a solution for this?