Max heap size

iam setting the max heap size to 1GB in java 1.4, but sometimes during the run of my application i do get Out of memory error.

If increasing the max heap size is the solution then how do i do that?

I have set the initial heap size to 64MB while my machine RAM is 2GB.

Please advice.

Thanks in advance

[331 byte] By [GauravDeva] at [2007-11-27 8:14:19]
# 1
Perhaps you should revise your code, not the JVM options. Memory leaks can consume all the memory even if is 32 MB or 1GB.Try using some profiling tool to see what happens with the memory.gl
Xtremebcna at 2007-7-12 19:58:51 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

> iam setting the max heap size to 1GB in java 1.4, but

> sometimes during the run of my application i do get

> Out of memory error.

> If increasing the max heap size is the solution then

> how do i do that?

> I have set the initial heap size to 64MB while my

> machine RAM is 2GB.

There are a number of contradictions in the above.

If you set your max heap size then you already know how to set it.

If you set it to 1 GB then it isn't 64MB.

jschella at 2007-7-12 19:58:51 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3
Do i need to increase heap size in steps for e.g. 100MB,500MB, and so on. or just randomly?
GauravDeva at 2007-7-12 19:58:51 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 4
> Do i need to increase heap size in steps for e.g.> 100MB,500MB, and so on. or just randomly?Increasing the maximum means that you must explicitly set a value for it.How you select that value is up to you.
jschella at 2007-7-12 19:58:51 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 5

> Do i need to increase heap size in steps for e.g.

> 100MB,500MB, and so on. or just randomly?

No need to increase it in steps. Just use the max heap size (-Xmx) that you think you need. The hard part is determining what you need. You say with -Xmx1g you sometimes get OutOfMemoryError. Do you expect that your app really uses 1G of heap or more? If so, that's fine, increase the -Xmx value to 1.5g (i.e., -Xmx1536m). If not, then try to find out what is consuming all the (presumably unnecessary) data.

FWIW, an initial heap size of 64m is really quite small if you eventually grow to 1G. I would try a larger value (say 512m).

jxca at 2007-7-12 19:58:51 > top of Java-index,Java HotSpot Virtual Machine,Specifications...