Now let's look at the specifics of runtime Byerly us and let's start with the method area under a heap 2
. 3
We will look at what goes into that area and also how heap and method area are interconnected. 4
Let's see how things get populated on heap and area we know the objects are created on heap on these 5
objects which include regular class instances that are created via a new operator Arrius are not class 6
objects when we say objects are stored on the heap. 7
What does that mean. 8
It means that we are mainly talking about the instance data present within those objects that is instance 9
literally sites on the heap. 10
So we have literally a look at space to an object based on how much of the instance it contains which 11
is based on the number of incidents variables and also Data Types of those instance variables. 12
No objects also can be in behavior which is nothing but methods. 13
The method however is something that is specific to the class or not to the object. 14
So that would be the last data and any class data will be stored in the metal area. 15
So that area is very strong. 16
Class data which is not limited to just method code but would also include Mad-Eye information like 17
the feeling team freetime on other stuff that people will see something that is all about classes while 18
heap is all about objects. 19
Non-X if we want to create an instance of a class in this because there are few things that can happen 20
. 21
First classloader checks of the class object for that particular class is already there on the heap 22
. 23
If it is not there it would then create a class object on the heap and the corresponding class data 24
itself in the method area and then JVM would also create a new instance of that class and store it on 25
the heap. 26
Now if a new object of the same class is to be created then only the object will be created and stored 27
on the heap. 28
Classloader knows that the class object and class data have already been created and so it does not 29
create them once again. 30
And we already know this. 31
Similarly as a program continues to exist even how most of getting creator on board heap on Methody 32
idea we can also see pointers going back and forth between heap and Methody. 33
On one of them is a byte original point or two. 34
Will see how this point will be useful not it's focus only on metadata and let's see what gets stored 35
in it that it's what gets stored as part of the class data. 36
What we will see here are general things that would be part of class data. 37
The exact implementation details are GBM specific classes they don't include Medine permission of the 38
type like fully qualified name of their type fully qualified name off its direct superclass fully qualified 39
name of any direct super interfaces whether that type is a class or interface. 40
And information about pipes modifiers like abstract final under access modifier public. 41
We know that such information is accessible through class object. 42
So what it means is that class object in dentally uses the class data which is stored in the metro area 43
. 44
So in the previous slide that was the reason why there was a connection from the class object to the 45
class data but the connection was by that action. 46
And that's because Glassner includes a reference back to the class object and this reference is needed 47
whenever access to class object is needed. 48
For example during class throating process classloader Fosdick's a class object for that pipe is already 49
on heap. 50
For that it may actually Serj the method area Boosey of the class data for the pipe exists and if it 51
doesn't exist it would then simply return the reference to the class object. 52
We know that classes in group feet like static and instance variables so Klausner don't include field 53
information like free name free type and any associated modifiers like static Feiner any access modifiers 54
under modifiers. 55
Volatile and transparent. 56
Whether it is related to multi-threading while consumed is related to serialization which isn't either 57
related topic well then intransient will be discussed later. 58
Note that here we are talking about free Mad-Eye information not the file happens to be an instance 59
variable with the parameter data type then the value itself will be stored on the heap. 60
But if the field happens to be a static variable with a primitive build up then the value will be stored 61
in the metro area itself. 62
Now if a field regardless of whether it is instance or static reference is an object then the object 63
will be on heap as data placed off objects. 64
But the reference itself which is the memory address of the object will be stored in the metro area 65
in case of static variables. 66
And I would strongly assume that the reference would be stored on a heap for instance variables as any 67
instance where you would go on the heap closeted I would also include runtime constant put me under 68
to discuss the dot classifiers would include something called constant pull on runtime constant it is 69
simply at runtime version of that constant pool. 70
It would basically include constants likely gross that is string literals are literally assigned to 71
primitive variables. 72
Constants can also include symbolic references which were discussed earlier in the lifetime of a type 73
while discussing the resolution strip classes also include methods subclass data. 74
I would also include method information like the method name methods Rikan type Nemeroff method parameters 75
and also type off those parameters with the arder maintain. 76
We know that methods can have modifiers too like static final access modifiers abstract synchronized 77
or native Glassner can include all this method modifier ARFs synchronize is related to multithreading 78
while native as the name implies would imply a native method. 79
Which would mean that the method itself will be implemented in some other programming language method 80
information will also include the actual code corresponding to the method body. 81
Next Klausner. 82
I will also include metor table which is simply an audio for references to instance methods. 83
Note that we are talking about instance methods here are not static methods so each reference is basically 84
a pointer to actual method bytecode itself which is also part of Gloucester to this table would be used 85
during method in location process. 86
That is when an instance method is invoked on an object then the method table would be used to find 87
the method that needs to be executed. 88
This is one reason for having a pointer from object on the heap with the class data. 89
So in invoking a method on an object JVM would simply follow the pointer fremd the object to the class 90
data and would then use the method table to find an exit to the target method and not admit that it 91
would also include references to any methods inherited from superclasses in the next lesson. 92
We will look at a very interesting example. 93
Very we'll see how their table will be useful. 94
So those are some of the things stored in the method area at the class level. 95
No one thing to note about method area is that prior to Djala 8 method area was located in the so called 96
permanent generation space are simply Bohmian. 97
Angela ate. 98
This area has been completely removed and the method area has been moved to near a heap and is not referred 99
to as model space. 100
So what was imagined then. 101
Now is Matt auspice the problem. 102
Namely does matter space because Metromedia and groats Mad-Eye information. 103
One reason for this change is because for bombon there was a default maximum size set of the max size 104
was reached and out of memory or would be generated with medals space. 105
There is not before max size that is system memory is the limit. 106
So you may not see order of memory error or even if you see it it may be delayed. 107
Another reason is related to improving the both foments of garbage collection process. 108
Earlier when discussing method tables we saw how JVM use method be able to invoke an instance method 109
that is at runtime. 110
The class due information associated with the type of the object has been used such type information 111
used at runtime is referred to as runtime type information or RTTY in shock. 112
RTD is also used to check the correctness of cost. 113
For example here an object of type subclass is assigned to a variable whose reference type is superclass 114
in the next statement. 115
A typecast is inserted to assign the same object to a variable whose reference type is of type subgraphs 116
. 117
Whether this is a valid cost or not is performed only at runtime. 118
On For that the class data of the object is consulted and run by so runtime type information is being 119
used here. 120
Arkadi is also used well-performing instance of operation. 121
For example here at runtime it needs to be checked whether or not the object type of the reference variable 122
is the class subclass so class state of the object is used here. 123
So these are a few places where type information is utilized on time. 124
So we have seen what constitutes method area and we have also seen how metatheory are a heap are interconnected 125
. 126
BLUEJACKET the resources section for some interesting pointers. 127
One of the pointer is a chapter from the book Inside the Java Virtual Machine by build winners. 128
Lots of material for the JVM stuff you're covering here comes from this book and all of it is available 129
online and the link posted in the resources section is a reference to the online version of the book 130
so you can take a look at that. 131
And that's about it for now.