Can you explain how the following are related? JVM, JVM stack, JVM heap, JVM method area, machine stack, machine heap, static declarations. Specifically, I am trying to verify that the JVM stack and heap are different from the actual machine stack and heap. I also would like to verify that class declarations go in the JVM method area, that objects go in the JVM heap, and that object references go in the JVM stack. I would also like to know how the keyword static affects things. And finally what is the implication of the keyword final (as pertains to memory use) Thank you. Matthew Son
the JVM (Java Virtual Machine) is an application written specific to a given operating system that maps compiled java bytecode into the native machine code that must be run on that operating system to get the desired effect. For instance, consider a = b + 1; Two platforms could execute integer addition completely differently. The JVM abstracts us, the java programmers, from this difference, and allows us to perform this operation in a single PLATFORM INDEPENDENT manner. This is why Java is touted as a write-once run anywhere language. Basically, the JVM is an environment in which java applications can be executed. The JVM heap is the amount of memory allocated within the JVM for use in allocating objects dynamically within an application. (Any time you instantiate an object with new). The JVM Heap is (I am assuming) a subset of the machine heap. The java interpreter (java.exe) would request an area of memory, and then handle the allocation of that memory throughout the execution of java applications. The JVM stack is just a runtime stack within the JVM. This stack is different from the machine stack, as the JVM is actually one application within an operating system. So, java.exe would be a process running on the machine, with its methods taking up real estate in the machine stack, while your java programs being executed through java.exe would take up real estate in the JVM stack. I don't know what the JVM method area is. the keyword static means that the related resource (a field or method) should be associated with the CLASS, and not the OBJECT. This means that if you have a static field declared within class SomeClass, there is only ONE copy of that field in the entire JVM. A non static field would exist in each instantiation of that class. Thus, a non static field would take up N times more memory in total, where N is the number of objects of type SomeClass currently in existence. the keyword final just means that something can't be changed. if used as a modification of a field, that field is a constant. if used as a modification of a method, that method can not be overridden in inherited classes. This question sounds like it's for a class...is it?
Paper jam tastes about as you would expect. Try some on this tiny ad:
how do I do my own kindle-like thing - without amazon