>>>>> Steinar Bang <[EMAIL PROTECTED]>:

> Right now I'm getting java.lang.OutOfMemory exceptions, when trying to 
> write a 12MB file in an HTTP POST:

> java.lang.OutOfMemoryError:
>         at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java)
>         at java.io.OutputStreamWriter.flushBuffer(OutputStreamWriter.java)
>         at java.io.OutputStreamWriter.flush(OutputStreamWriter.java)
>         at java.io.BufferedWriter.flush(BufferedWriter.java)
>         at java.io.PrintWriter.newLine(PrintWriter.java)
>         at java.io.PrintWriter.println(PrintWriter.java)
>         at RepositoryCmd.send(RepositoryCmd.java:72)
>         at Upload.main(Upload.java:32)

> I'm guessing that the culprit here, is the ByteArrayOutputStream.
> However, why it should crash at a mere 12MB is beyond me.  According
> to top it gives up way before it can make a serious impact on the
> available swap space?

> Is there some command line argument I have to give to the java
> runtime, I wonder?

Yes, there is. "-mx<number>" sets the maximum heap size.  This 
is 16MB or thereabouts by default.

Setting it to 24000000 and to 40000000 didn't help, but setting it to
80000000 did.

I guess reallocating the byte array when neccessary, requires a bit of
space?  Hm... maybe I can set the size of the byte array before
writing into the ByteArrayOutputStream?  I know how large it at least
has to be from the size of the file I'm trying to POST.


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to