This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Heap Size

 
kodi pitta
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have set the max heap size for my java program to 512m, by specifying
java -Xmx512m.
However, when I run a test program that invokes java.lang.Runtime.maxMemory(), which is the amount of memory that the JVM will attempt to use, I don't see 512m, instead I only see about 510MB.
How does one explain the difference ?
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which java version are you using.
When I tested, it is giving 576 MB! In fact, it is actually giving 64MB more than what ever I specify.
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay...the problem I posted is a bug, which was fixed in 1.4.2.
Here are the details.
But I don't have any answer to the initial question.
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I don't have any answer to the initial question.
Turns out to be another reported bug:
Bug Id 4391499: java.lang.Runtime.maxMemory() returns value different from -Xmx option.
However, Sun set the status to "closed, will not be fixed" with the following explanation:
Not a bug. The interpretation of the -Xmx flag is VM-dependent. Some VMs, including HotSpot, enforce a lower bound on the effective value of this option.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic