[4060] in java-interest

home help back first fref pref prev next nref lref last post

memory allocation pool size

daemon@ATHENA.MIT.EDU (Larry Lam)
Fri Dec 8 16:46:08 1995

Date: Fri, 8 Dec 1995 11:59:55 -0800
From: Larry.W.Lam@Eng.Sun.COM (Larry Lam)
To: java-interest@java.Eng.Sun.COM


Hi all:

I have a relatively small standalone program that create a lot of
small objects and I keep getting "OutOfMemeoryError" error.
I increase the memory allocation pool increment of 4Mb (using -mx 
option in java), and finally the program was able to complete 
with "-mx64m".

Here is the semi-pseudocode of the program:

	for (int i = 0; i < 1700; i++) {
		create a Hashtable
		create 200 objects (100 keys and their associated value)
		store the objects (keys and values) into hashtable
		save the hashtable
		// just in case...
		run garbage collection every 100 interations
	}
		
At the end of this code segement, there are ~340,000 objects stored
in 1700 hashtables.

Now, here is the puzzle.  When I increse the size of the objects, (they 
can be totaled to ~20MB increase in size), the new program was able to 
complete with the same size of memory pool ("-mx64m")!!  Any logical
explanation?

In general, is there any way to estimate memory usage of a java program?
It would be nice to know the size of a object reference and memory 
overhead for each object so one can preallocate enough memory.

Any information would be appreciated.

larry lam
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post