Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

garbage collection

 
william kane
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do Runtime.getRuntime().totalMemory() and
Runtime.getRuntime().freeMemory() return?
When i create new objects i expect the freeMemory to reduce and totalMemory to increase, but, the the totalMemory is remaining constant.
is my expectaion right?
 
Steve Deadsea
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
freeMemory + usedMemory = totalMemory
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve is right, totalMemory is a constant. It's configurable at initialization time, and that's it. "used memory" is the value you expect to increase with object creation.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope. Steve's equation is right - but total memory is not a constant.

Total memory refers to the total heap size currently allocated to the JVM. This can and does change over time , if the application attempts to use more memory, and the JVM has not yet used its allowed maximum. That's why there's a difference between the -ms and -mx options when invoking the JVM.
[ February 27, 2002: Message edited by: Jim Yingst ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic