classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] RFC: [Patch] rewrite of classpath/gnu/java/net/protocol


From: Chris Burdess
Subject: Re: [cp-patches] RFC: [Patch] rewrite of classpath/gnu/java/net/protocol/http/*
Date: Tue, 13 Sep 2005 09:31:58 +0100

David Daney wrote:
As I threatened last week, I made some major changes to the gnu.java.net.protocol.http package. ...

The current version reads the entire body of a HTTP response in to a memory buffer (ByteArrayResponseBodyReader) and if user code needs the content it gets a ByteArrayInputStream wrapped around the buffer.

There are several problems with this approach The main one is that if the response is larger than one half of the heap limit (a copy of the data is made so you need space for two copies) You get an OutOfMemoryError.

Indeed. A specialised implementation of both ResponseBodyReader and InputStream that does not make two copies of the byte array would solve that problem.

And related is that if the response is larger than Integer.MAX_VALUE you run into the java language limit on array sizes.

True, however most current machines will run out of memory before that happens. As I said before, if you want to stream arbitrarily large entities over HTTP you would be advised to use an API specialised for the purpose (namely HTTPConnection and ResponseBodyReader).

Here is an outline of what I did:

... I did not bother to check or investigate.  ...
... More testing is probably needed.

Comments?

You would probably have a better chance if you threw out all the inetlib classes and started from scratch with a pull-based client.
--
Chris Burdess





reply via email to

[Prev in Thread] Current Thread [Next in Thread]