readObject memory consumption

Nicolás Ernesto Kuzminski nkuzminski@gmail.com
Tue Nov 30 22:19:00 GMT 2004


I'm using the 4.0 Windows port downloaded from
http://www.thisiscool.com/gcc_mingw.htm. It has been very useful for
me, since the libjcj in 4.0 is way more complete than the one on the
current releases. And I'm also using SWT and other things that works
out of the box on this special release.
But now I'm facing this issue, wich I don't know if it happens on the
current snapshots. Really, I've tried a bit to build the snapshots,
and failed. I lack the experience to do it.
So, here it is. The problem is the big memory consumption  that the
readObject part of the following testcase shows (Just see it on the
Task Manager). This is a very much simplified situation than the one
I'm working on, but is enough to show the problem.  Any ideas?

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class prueba {

	public static void main(String[] args) throws Exception {
		
		String filename = "bla";

		System.out.println("Out");
		ObjectOutputStream out = new ObjectOutputStream(new
FileOutputStream(filename));
		for (int i=0;i<1000000;i++) {
			out.writeObject(new String());
			out.reset(); 
		}
		out.close();
		
		System.out.println("In");
		ObjectInputStream in = new ObjectInputStream(new FileInputStream(filename));
		try {
			while (true) 
				System.out.print(in.readObject());
		} catch (Exception e) {}
		in.close();
	}
}

-- 
        Saludos, Nico.



More information about the Java mailing list