Not look at some command line options that are related to heap memory on these options or passed the 2
July interpreter while writing large programs you could very well encounter situations where you may 3
run out of memory and you can get all out of memory errors. 4
One reason could be you do creating too many objects on file that we can simply increase the heap size 5
. 6
But there can also be memory leaks Yes some memory leaks can still be that Angela despite all the hard 7
work that GC does. 8
We will soon see how memory leak is possible in Java. 9
But for now let's see how we can add just a heap size. 10
We are command line options. 11
Howard in the simple program called GC them all and it declares an end date which is a static variable 12
and it has on a million entries. 13
OK. 14
And each entries and which is basically 4 bytes. 15
So if you multiply that so you would get around eight point four megabytes of data. 16
So this data structure. 17
It's the size of it would be eight point four megabytes. 18
So it's going to go ahead and run it. 19
But let's go into the run configurations and past the options that we want to pass. 20
So let's go into arguments here. 21
And so these are your arguments and you would pass the options here. 22
So there are some options here which I have already included under do important things that we need 23
to note here as x and x and x and x. 24
So those are heap related options. 25
X is the minimum amount of memory that would be a look at it to heap memory on that is 30 megabytes 26
is what I'm passing on. 27
X X would be the max. 28
Max amount of memory that would be a look at it here. 29
And right now it's both of them are 13 and B and if you change it to G here in sort of that would be 30
gigabytes on it for display it would be kilobytes of data on print. 31
GC dense is basically we want to print the gcd details. 32
So it's like GC logging. 33
So when our GC happens garbage collection happens it would print all the details of the memory like 34
the summary of the memory before GC and after. 35
GC OK so the memory the summary of the heap memory and we are forcing the GBM to use serial GCs serial 36
collector. 37
OK. 38
So 39-B is good enough since our data is only 8.4 M-B. 39
Now if you run it everything is fine. 40
GC did not run yet because there are a sufficient amount of memory and it just did not trigger a GC 41
. 42
And but still it prints a summary of the heap memory and thats because of the print gcd does that would 43
because of that option we have this. 44
So its just printing some details about the young Mammootty So this is a memory information and there 45
is Edan space from space to space and so on and so to look at it was this much for poor Temby and for 46
the older generation. 47
I don't mind them BS has been I look at it and there is also the model space. 48
I'm using Java 8 so model space. 49
So we have metalsmiths to store the metro area to test a class data and we know that it is Bardolph 50
actually the need to memory. 51
But that information is also getting printed here. 52
Now let's just do something go back change the minimum memory to be here. 53
So Maxxis does not see a blind run. 54
Now you can see this new line here. 55
So this is coming because initially GBM hired has only two M-B that's what we specified using the X 56
M-S Frank. 57
So with that it tried to look at space for this Adeyemi M-B and it free. 58
So that's what this says location has value. 59
And because of that GC has again iron. 60
This is a four year GC cycle. 61
So this is the information about this say something about young collection because a full GC would entail 62
collection all collection and also metalsmiths collection. 63
That's why you see Matt auspice yet at the very end here is for the oil collection. 64
OK. 65
So initially for the collection for the new generation there was around one maybe and I don't know seven 66
sixty eight kilo bytes for all generations. 67
So if you sum up it's around to M-B. 68
So that's what has been a look at it initially and here it just says that before a young collection 69
has been done this is the amount of memory that was used within one generation of 3:45 kilobytes. 70
And after DC has been performing it you know it was using 128. 71
So something has been freed here. 72
And for the same thing for the op ed you're on so 1:46 and it increased OK before collection icles 1:46 73
after collection it is 273. 74
So maybe most likely something got passed got promoted from the end generation to the older generation 75
. 76
Unfought Let's see what it is for them or just miss them or just. 77
2400 kilobytes before or after so nothing has changed here. 78
So that's when we are just. 79
Now let's just go back and let's change it. 80
Change District 12 maybe and it should still work because we have our data is only eight point four 81
on we to LMB. 82
But to our surprise it free. 83
And the reason for that is because if you see here for the younger generation the space available is 84
around 3700 which is less than 8.4 and here eight point one and B has been allocated to older generation 85
which is also an eight point four. 86
So the thing it failed is because none after Regence had enough space to look at it all put together 87
they had more than this but individually they did not have enough space. 88
So that was a main reason for this failure on their Ronsard. 89
See is happening here. 90
So the first you see was just like it tried with two M-B space and it failed. 91
Then it increased it to grow let me understand afraid. 92
OK. 93
So on both of them are full of uses but just that in the second Do you see for some reason it was doing 94
it only on the order collection. 95
Okay. 96
So thats why you have this out-of-memory error on which is we are out of memory you do. 97
There is not there isn't enough Jawa space. 98
So only is out of this is to increase the heap memory back to 13 and we are maybe more than that but 99
there is also one Hokke which we can do. 100
And let me just so that we I don't think you would ever do this but what you can do is we can force 101
me and disaffiliate here you can force GBM to restrict young generation size to be around 1 and be under-staffed 102
it should be a look at it to or generation. 103
Now if you do that we are fine. 104
It works fine. 105
And that's because for the generation that is I don't want M-B on for the old generation now it has 106
around 9 M-B. 107
So an item be sufficient to horded this. 108
Okay. 109
So just that's just for a hike. 110
Just wanted to show that. 111
So that's about it. 112
So the main thing is the Exham as on the economics fracs and you might be using it in your professional 113
life do. 114
And there are many other flaks that we can use for example for model space. 115
We can specify the size and there are some flak for that. 116
I would try to include some additional pointers and also some additional notes in the resource section 117
so you can look up there where our catering group. 118
Some other Flack's that we can use. 119
Okay. 120
So that's the main thing. 121
So that's how you can I just heap memory size. 122
Okay. 123
Thank you.