wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes a question on Runtime.getRuntime().totalMemory() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "a question on Runtime.getRuntime().totalMemory()" Watch "a question on Runtime.getRuntime().totalMemory()" New topic
Author

a question on Runtime.getRuntime().totalMemory()

cake naiyou
Greenhorn

Joined: Apr 29, 2011
Posts: 27
The following function is used to compute memory usage.



I do not understand how to understand "Runtime.getRuntime().totalMemory()"? In specific, how to understand the relationships connecting "Runtime", "getRuntime()" and "totalMemory()"?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19653
    
  18

Runtime is an abstract class. There is no direct way to instantiate it. It has a static method to get an instance of some unknown subclass. This method is called getRuntime(). Therefore, Runtime.getRuntime() returns an instance of a subclass of Runtime.
totalMemory() is an instance method that you call on that instance. Your single line is similar to this:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a question on Runtime.getRuntime().totalMemory()
 
Similar Threads
Memory leak
Increase memory for tomcat
garbage collection
How to find out how much memory machine has.
Optimization Java Code - performance Vs memory