3

I have got the heap dump at point of time . is there a way i can see how many/which probable objects( or how much probable memory) will be reclaimed(free) once another GC(minor/major) GC is run ?

I have access to Memory Analyzer tool(MAT),jvisualVM,Jprofiler tools and can use any one of them

enter image description here

trincot
  • 317,000
  • 35
  • 244
  • 286
user3198603
  • 5,528
  • 13
  • 65
  • 125
  • In the System (and Runtime) class(es) there are methods to querry the current free memory for the current JVM. I dont know the exact method names, but a quick lookaround will do. (It is wel documented) – n247s Sep 22 '16 at 13:28
  • Usually heap dump do not contains such objects because creating heap dump is invoking GC (if you do not ask specificaly not to). Which tool do you use btw? – talex Sep 22 '16 at 13:32
  • @talex please see mine update in post – user3198603 Sep 22 '16 at 13:34
  • here the answer http://stackoverflow.com/a/20405267/3656904 – talex Sep 22 '16 at 13:40

1 Answers1

1

You can try these references go to the doc pages on that):

Update. Just noticed you have MAT so try the first thing Update 2. Example

Also could you please share more context on what are you trying to accomplish with this? (runreachable_objects tab

Ivan
  • 3,781
  • 16
  • 20
  • on overview tab it displays `Size 143 MB Classes 12K Objects 2m Classloader 120` but when i clean unreachable object histogram its displays `shallow heap size as 864,367,304(864MB)` which one is correct ? – user3198603 Sep 22 '16 at 13:50
  • @user3198603 can you please post all of that with screenshots? like when you just load it, which action do you trigger and what you see afterwards – Ivan Sep 22 '16 at 14:04
  • @Ival please see screen shot attached. On details page it displays total size as 157.3MB but when i click on unreachable object it displays total size as 864 MB. Does it mean 864MB size are for unreachable object and 157MB size are for reachable object ? – user3198603 Sep 22 '16 at 14:21
  • i am trying to see what is the size of dead/unreachable objects that can be cleared by next GC – user3198603 Sep 22 '16 at 15:00
  • @user3198603 I went ahead and attached an example. In my case it's ~13Mb of unreachable objects (and 40Mb of reachable ones in the Overview tab in my case) – Ivan Sep 22 '16 at 15:01
  • so after next GC most probably you'll 143Mb of alive data (or maybe more) and 864Mb will go away (although that depends on GC algorithm alot, some are latency based so they'll clean up as much as they can in the time they have allocated) – Ivan Sep 22 '16 at 15:03
  • an object being unreachable does not guarantee that the next GC will free the memory. Generational and region-based collectors don't collect everything unless necessary. – the8472 Sep 22 '16 at 16:06
  • @Ivan how come 143 MB data of live data and 864 MB data will go away after next GC? As you have just 13MB of unreachable object at this point of time this data is the only probable candidate to go away . Right ? – user3198603 Sep 22 '16 at 16:50
  • @the8472 I agree `an object being unreachable does not guarantee that the next GC will free the memory. ` That depends whether minor or major GC getting triggered as minor will collect only unreachable objects from young generation not from old generation. – user3198603 Sep 22 '16 at 16:52
  • @user3198603 1) 143Mb of live data won't go away in your case 2) In my case yes, 13Mb is what can go away during next GC – Ivan Sep 23 '16 at 09:44
  • Yes i mentioned it for your case only – user3198603 Sep 23 '16 at 14:23