This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Help regarding Runtime.java  RSS feed

 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote the following program.


result:
==============
Max mem 66.650112 mb
free mem 1.9108 mb
total mem 2.031616 mb
==============
I understand max memory is the total amount of memory that the jvm can use for heap or in other words its the max heap size..
How about total memory and free memory..does the total memory mean total free memory? if yes , then why executing such a small program (which doesnot create any object) consume such a big amount of memory ?
Or total memory is for this thread of execution and can be extendable to max mem.
please explain
Thanks,
Rahul B

[Added code tags - Paul Sturrock]
[ September 11, 2006: Message edited by: Paul Sturrock ]
 
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Total memory" is the current amount of virtual memory allocated to the Java heap. Some of that memory will be unused, at any time; that's the "free memory". Some of it will be used by objects that are ready for garbage collection, but not yet freed. Some will be used by active objects.

Depending on the settings specified when starting the JVM (e.g. via the "java" command), Java may increase or decrease the amount of virtual memory allocated to the Java heap, while your program runs. There is a limit to how big it is allowed to be; you can control that when starting the JVM. It would be nice if "max memory" reported this limit, but it doesn't. In fact, it reports a somewhat higher value, which I've never quite understood. The value of "max memory" does vary directly with the maximum heap size, but it is not the same value.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!