maximum memory for gcj-compiled executable?
Lars Andersen
lars@rimfaxe.com
Wed Apr 9 19:10:00 GMT 2003
On Fri, 2003年04月04日 at 13:44, Lars Andersen wrote:
> Ranjit Mathew wrote:
> >>I have made this simple program that reads a web page, and then does
> >>nothing with it ;)
> >>
> >>Compile it under win32/mingw using Mohan's latest GCC3.3
> >>
> >>Run it.
> >>
> >>The heap soon stabilizes and stays put (about 1000KB)
> >>
> >>Now open the task manager and watch memory usage slowly grow and grow
> >>and grow....
> >
> >
> > Yes, I see this behaviour too. Even after statically allocating
> > "buf" and "output" (and remembering to output.setLength( 0) at the
> > start of read( )) and explicitly closing streams and connections
> > and even omitting the creation of the intermediate strings...i.e.
> > the mere act of reading is causing this increase!
> >
> > Don't know what's causing it and I wouldn't venture a guess
> > either. :-(
> >
> > Ranjit.
>>> Just tried it reading a file instead of reading a web page.
> This did not exhibit any growing mem usage.
>> This is likely a problem in java.net / mingw
I tried modifying TestThread.java (see it in
http://gcc.gnu.org/ml/java/2003-04/msg00054.html ), to write and read
directly to java.net.Socket instead of using java.net.HttpURLConnection.
With this change the memory leak disappears.
Maybe this is a clue to where the bug is.
Please note that this way of conducting a http request is much, MUCH
slower than using java.net.HttpURLConnection, so it takes a while for it
to stabilize...
Here is how the new performRequest() reads :
....
public void performRequest()
{
String uri = "/index.html";
String host = "www.apache.org";
int port = 80;
SocketURL surl = new SocketURL(host);
surl.setPort( port );
surl.setMethod("GET");
surl.setHeader("Host",""+host+":"+port);
surl.connectSocket();
java.io.DataInputStream dis = surl.getData(uri,null);
String res = surl.readDataInputStream(dis);
System.out.println("Length of page="+res.length() );
}
....
Attached:
SocketURL.java
TestThread.java
/Lars Andersen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TestThread.java
Type: text/x-java
Size: 2801 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java/attachments/20030409/bdec3e1c/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SocketURL.java
Type: text/x-java
Size: 2482 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java/attachments/20030409/bdec3e1c/attachment-0001.bin>
More information about the Java
mailing list