lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
Subject Re: 2.1-dev memory leak?
Date Fri, 01 Dec 2006 15:01:17 GMT
Otis Gospodnetic wrote:
> Hi Mike,
> 
> Thanks for looking into this.  I think your stress test may match my production environment.
> I think System.gc() never guarantees anything will happen, it's just a hint.
> 
> I've got the following in one of my classes now.  Maybe you can stick it in your stress
test and look at that last number at the bottom of this snippet.
> 
>     private static final MemoryMXBean bean = ManagementFactory.getMemoryMXBean();
> ...
>         LOG.info("Bean: " + bean);
>         LOG.info("Heap memory usage: " + bean.getHeapMemoryUsage());
>         LOG.info("Non-heap memory usage: " + bean.getNonHeapMemoryUsage());
>         LOG.info("Objects pending finalization: " + bean.getObjectPendingFinalizationCount());
>         long freeMemBefore = Runtime.getRuntime().freeMemory();
>         LOG.info("Running garbage collector via bean...");
>         bean.gc();
>         long freeMemAfter = Runtime.getRuntime().freeMemory();
>         LOG.info("Total Memory      : " + Runtime.getRuntime().totalMemory());
>         LOG.info("Max Memory        : " + Runtime.getRuntime().maxMemory());
>         LOG.info("Free Memory Before: " + freeMemBefore);
>         LOG.info("Free Memory After : " + freeMemAfter);
>         long memDelta = freeMemAfter-freeMemBefore;
>         LOG.info("Free Memory Now   : " + memDelta);
>         LOG.info("Heap memory usage: " + bean.getHeapMemoryUsage());
>         LOG.info("Non-heap memory usage: " + bean.getNonHeapMemoryUsage());
>         LOG.info("Objects pending finalization: " + bean.getObjectPendingFinalizationCount());
> 

Neat -- this is a nice interface!  OK, yes indeed after calling
System.gc() the "object pending finalization count" is often
non-zero (and often very high).  Apparently System.gc() is very
much "a suggestion".

Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message