After finishing the java program the young gen
, old gen
, perm gen
will be full garbage collected, And here garbage collector is also a program, so who will do the garbage collection for the garbage collector? or will it exit just like that?
When you start any process, the memory for that is coming from the operating system.
When that process ends, all of the memory goes back to that operating system.
So, the second the jvm process ends, all its memory becomes "free" again.