logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rpo...@apache.org
Subject svn commit: r1525473 - in /logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async: AsyncLoggerConfigHelper.java RingBufferLogEventTranslator.java
Date Sun, 22 Sep 2013 23:43:33 GMT
Author: rpopma
Date: Sun Sep 22 23:43:33 2013
New Revision: 1525473

URL: http://svn.apache.org/r1525473
Log:
release reference to most recent LogEvent from translator object when work is done so object
can be GC-ed

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigHelper.java
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEventTranslator.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigHelper.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigHelper.java?rev=1525473&r1=1525472&r2=1525473&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigHelper.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigHelper.java
Sun Sep 22 23:43:33 2013
@@ -281,6 +281,7 @@ class AsyncLoggerConfigHelper {
     public void callAppendersFromAnotherThread(final LogEvent event) {
         currentLogEvent.set(event);
         disruptor.publishEvent(translator);
+        currentLogEvent.set(null); // clear reference to allow GC
     }
 
 }

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEventTranslator.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEventTranslator.java?rev=1525473&r1=1525472&r2=1525473&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEventTranslator.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEventTranslator.java
Sun Sep 22 23:43:33 2013
@@ -53,6 +53,27 @@ public class RingBufferLogEventTranslato
         event.setValues(asyncLogger, loggerName, marker, fqcn, level, message,
                 thrown, contextMap, contextStack, threadName, location,
                 currentTimeMillis);
+        clear();
+    }
+
+    /**
+     * Release references held by this object to allow objects to be
+     * garbage-collected.
+     */
+    private void clear() {
+        setValues(null, // asyncLogger
+                null, // loggerName
+                null, // marker
+                null, // fqcn
+                null, // level
+                null, // data
+                null, // t
+                null, // map
+                null, // contextStack
+                null, // threadName
+                null, // location
+                0 // currentTimeMillis
+        );
     }
 
     public void setValues(final AsyncLogger asyncLogger, final String loggerName,



Mime
View raw message