For all: I'm doing a comparision based on report from Michael E. Moores using the same
program (see bellow) and anotating reports about memory usage (and, of course,
stability). Michael reported a crash after 45000 loops in Linux JDK1.2.2 ("linux 2.2,
blackdown 1.2 (glibc 1.2.1)").
My comparision consist in executing same program using JDK 1.2.2 in a K6II300/96Mb
with WinNT4 using -classic option (I have hotspot installed).
My test started with the following:
loops RAM Virt. Mem. rt.free()
start 7124K 5072K 2097144
15000 7128K 5072K 2097144
80000 7128K 5072K 2097144
150000 6764K 5072K 2097144 <--!!!!!
300000 6764K 5072K 2097144
As anyone can see, we have no crash, and memory comsuption has decreased (why??? I
don't know!) after some time...
Anyone can test the same program in Linux to get another comparision (one more than
Michael - this can be an issue about a lib or something).
Other thing is interesting: the "forced garbage collecting every 5 seconds" does
nothing. My tests with JFC show that this conding make sense, but for this example not.
Simple copy code bellow to a file called "newtest.java", compile and execute.
Edson Richter
import java.io.*;
import java.net.*;
public class newtest extends Thread {
URLConnection yc;
Runtime rt = Runtime.getRuntime();
String inputLine;
int thflag;
public static void main(String[] args) throws Exception {
new newtest( args );
}
public newtest( String [] args ) {
int arg, i = 0;
thflag = 0;
arg = Integer.parseInt( args[ 0 ] );
this.start( );
while( true ) {
i ++;
work( i );
}
// thflag = 1;
}
private void work( int i ) {
try {
if( i % 100 == 0 ) {
System.out.println( i + ": " + rt.totalMemory( ) + " bytes\n" );
}
URL yahoo = new URL( "http://127.0.0.1/" );
yc = yahoo.openConnection( );
BufferedReader in = new BufferedReader(new
InputStreamReader(yc.getInputStream()));
while((inputLine = in.readLine()) != null) {
//System.out.println(inputLine);
}
in.close();
in = null;
yahoo = null;
} catch( IOException e ){ System.out.println("IO EXC\n"); thflag = 0;}
}
public void run( ) {
while(thflag == 0 ) {
try {
this.sleep( 5000 ); // Encourage Garbage Colection every 5 seconds
rt.gc( );
} catch( Exception e ) {}
}
}
}
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]