• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to find out how much memory machine has.  RSS feed

 
Josh Johnson
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way to determine how busy the machine you are running on is? Is there a way to find out how much free memory the machine has or how many cpu cycles are not idle?
Thanks.
Josh
 
Aleksey Matiychenko
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Runtime.getRuntime().freeMemory()
and
Runtime.getRuntime().totalMemory()
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
However, these only tell you how much memory the JVM currently has allocated to it, and how much of that is free. Typically as your program grows bigger, the JVM will receive more allocation, up to some maximum. I don't know a platform-independent way of accessing info about the overall memory and load, outside of the JVM. You may need to use Runtime.exec() to query the OS directly.
 
Josh Johnson
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay. Thanks guys.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!