Menu

#81 Out of memory

open
nobody
None
5
2013-02-05
2013-02-05
No

I'm getting out of memory errors (heap space) when uploading large files using current version in CVS (1.2) under Java 6.

It's always thrown on line 299 of REST.java.

Because I'm using an InputStream for posting, we don't know the size of the file. The Java 6 API docs says we should use chunking:

http://docs.oracle.com/javase/6/docs/api/java/net/HttpURLConnection.html#setChunkedStreamingMode%28int%29

Enabling this on the HttpURLConnection does fix my problem.

Additionally, I think line 300 should read:

out.write(buf,0,res);

instead of:

out.write(buf);

Otherwise the wrong stuff might be written.

Attached is a modified REST.java and a patch.

Discussion

  • James Carnegie

    James Carnegie - 2013-02-05

    Modifed version of REST.java that fixes bug

     
  • James Carnegie

    James Carnegie - 2013-02-05

    191a192
    > conn.setChunkedStreamingMode(512);
    216c217
    <
    ---
    >
    300c301
    < out.write(buf);
    ---
    > out.write(buf,0,res);

     

Log in to post a comment.