Quantcast

Calling Runtime.gc twice

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Calling Runtime.gc twice

David Sinclair
Hi all,

I was hoping for an explanation of why calling Runtime.gc() twice shows a significant improvement in memory reclaimed as opposed to calling it once.

Thanks

daveĀ 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling Runtime.gc twice

kirk@kodewerk.com
Most likely the second GC is reclaiming Reference types identified during the first collection. Finalization is a likely candidate as it take one collection to get it into the reference queue, the queue is then process and the finalized object can finally be reclaimed.

Kind regards,
Kirk Pepperdine

> On Mar 31, 2017, at 8:53 PM, David Sinclair <[hidden email]> wrote:
>
> Hi all,
>
> I was hoping for an explanation of why calling Runtime.gc() twice shows a significant improvement in memory reclaimed as opposed to calling it once.
>
> Thanks
>
> dave

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling Runtime.gc twice

David Sinclair
Ah, didn't think of that. I'll take a couple of heap dumps to try and confirm that.

Thanks Kirk

On Friday, March 31, 2017, Kirk Pepperdine <[hidden email]> wrote:
Most likely the second GC is reclaiming Reference types identified during the first collection. Finalization is a likely candidate as it take one collection to get it into the reference queue, the queue is then process and the finalized object can finally be reclaimed.

Kind regards,
Kirk Pepperdine

> On Mar 31, 2017, at 8:53 PM, David Sinclair <dsinclair@chariotsolutions.com> wrote:
>
> Hi all,
>
> I was hoping for an explanation of why calling Runtime.gc() twice shows a significant improvement in memory reclaimed as opposed to calling it once.
>
> Thanks
>
> dave

Loading...