开发者

Memory Comsuption in Java Programs running on different Computers

I have a java program that realizes a lot of mathematical operations and handle with a lot of object instances. But the most interesting I noticed is that in different computers, the memory comsuption is drastically different.

On a Intel Core 2 Duo (2Ghz) with 2Gb of ram and running WinXP 32bits- my program uses around 185mb of memory. The JVM properties are -Xms768m -Xmx1300m (If I set more than 1300m, I get an out of memory exception at runtime).

O开发者_如何学运维n a Turion X2 (2.1Ghz) with 3Gb of ram and running WinXP 32bits - my program uses around 380mb of memory. The JVM properties are -Xms768m -Xmx1600m (1600m is the most I could set that my computer run the program).

Do you know why such a big difference?


I imagine the garbage collector is more lenient with more memory to play with.


To do a proper comparison you should:

  • set the exact same VM parameters.
  • state if the VM is the same.
  • run the program with the exact same input parameters

Most likely it is as Gary suggests, just the VM jumping around or choosing to GC at some different time than when you are looking. If the consumption is 'real' it could be some difference in how hotspot (which I guess looks at processor cache sizes) chooses to pack your java objects member fields into a contiguous structure -- perhaps it is adding a few bytes of pad (to some object you have alot of) on on platform and not on the other.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜