logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "jiangguilong (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4J2-1167) Memory leak for org.apache.logging.log4j.core.async.RingBufferLogEvent
Date Wed, 21 Oct 2015 14:08:27 GMT

    [ https://issues.apache.org/jira/browse/LOG4J2-1167?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14966858#comment-14966858
] 

jiangguilong commented on LOG4J2-1167:
--------------------------------------

I find the size is set by AsyncLogger.RingBufferSize ,this default value is 256*1024=262144
here is refering code:
=============================================
private static int calculateRingBufferSize() {
        int ringBufferSize = RINGBUFFER_DEFAULT_SIZE;
        final String userPreferredRBSize = PropertiesUtil.getProperties().getStringProperty("AsyncLogger.RingBufferSize",
                String.valueOf(ringBufferSize));
        try {
            int size = Integer.parseInt(userPreferredRBSize);
            if (size < RINGBUFFER_MIN_SIZE) {
                size = RINGBUFFER_MIN_SIZE;
                LOGGER.warn("Invalid RingBufferSize {}, using minimum size {}.", userPreferredRBSize,
                        RINGBUFFER_MIN_SIZE);
            }
            ringBufferSize = size;
        } catch (final Exception ex) {
            LOGGER.warn("Invalid RingBufferSize {}, using default size {}.", userPreferredRBSize,
ringBufferSize);
        }
        return Integers.ceilingNextPowerOfTwo(ringBufferSize);
    }
===========================================

My question is why the default size is so big?

> Memory leak for  org.apache.logging.log4j.core.async.RingBufferLogEvent
> -----------------------------------------------------------------------
>
>                 Key: LOG4J2-1167
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1167
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.4
>         Environment: CentOS release 6.5 (Final)
> linux version 2.6.32-431.el6.x86_64
> Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
> Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
>            Reporter: jiangguilong
>
> when I start server,the ring buffer occupy about 20MB+ in heap ,
> here is heap message:
> {noformat}
> Class Name                                                      |   Objects | Shallow
Heap | Retained Heap
> -----------------------------------------------------------------------------------------------------------
> .*RingBuffer.*                                                  |           |       
      |              
> com.lmax.disruptor.RingBuffer                                   |         1 |       
  144 | >= 22,020,440
> org.apache.logging.log4j.core.async.RingBufferLogEvent          |   262,144 |   20,971,520
| >= 20,971,552
> org.apache.logging.log4j.core.async.RingBufferLogEventTranslator|        44 |       
3,168 |      >= 3,168
> org.apache.logging.log4j.core.jmx.RingBufferAdminMBean          |         0 |       
    0 |        >= 384
> org.apache.logging.log4j.core.async.RingBufferLogEventHandler   |         1 |       
   24 |         >= 32
> com.lmax.disruptor.RingBuffer$1                                 |         0 |       
    0 |         >= 32
> org.apache.logging.log4j.core.jmx.RingBufferAdmin               |         1 |       
   24 |         >= 24
> com.lmax.disruptor.RingBufferFields                             |         0 |       
    0 |         >= 24
> org.apache.logging.log4j.core.async.RingBufferLogEvent$Factory  |         1 |       
   16 |         >= 16
> com.lmax.disruptor.RingBufferPad                                |         0 |       
    0 |              
> Total: 10 entries (11,119 filtered)                             |   262,192 |   20,974,896
|              
> -----------------------------------------------------------------------------------------------------------
> {noformat}
> I think here is memory leak,do you agree ?
> ======================
> here is my log4j2  file config:
> {code}
> <?xml version="1.0" encoding="UTF-8"?>
> <configuration status="warn" monitorInterval="1800" shutdownHook="disable"  >
> 	<properties>
> 		<property name="SERVER_ID">1</property>
> 		<property name="GAME_NAME">ST</property>
> 		<property name="PID">1</property>
> 		<property name="SERVER_NAME">game</property>
> 		<property name="LOG_HOME">/data/log/${SERVER_NAME}/${SERVER_ID}</property>
> 		<property name="LINGYU_HOME">/data/stat/lingyu/${SERVER_NAME}/${SERVER_ID}</property>
> 	</properties>
> 	<appenders>
> 		<Console name="Console" target="SYSTEM_OUT" follow="true">
> 			<PatternLayout pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread][%c{1}]
- %msg%n" />
> 		</Console>
> 		<RollingRandomAccessFile name="DevLog" fileName="${LOG_HOME}/${SERVER_NAME}"
> 			filePattern="${LOG_HOME}/${SERVER_NAME}.%d{yyyy-MM-dd-HH}.log" immediateFlush="false">
> 			<PatternLayout pattern="%date{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread][%c{1}]
- %msg%n" />
> 			<Policies>
> 				<TimeBasedTriggeringPolicy interval="1" modulate="true" />
> 			</Policies>
> 		</RollingRandomAccessFile>
> 		<RollingRandomAccessFile name="LingyuLog"
> 			fileName="${LINGYU_HOME}/${SERVER_NAME}"
> 			filePattern="${LINGYU_HOME}/${SERVER_NAME}.%d{yyyy-MM-dd-HH-mm}.log">
> 			<PatternLayout pattern="%msg%n" />
> 			<Policies>
> 				<TimeBasedTriggeringPolicy interval="5" modulate="true" />
> 			</Policies>
> 		</RollingRandomAccessFile>
> 	</appenders>
> 	<loggers>
> 		<!-- 3rdparty Loggers -->
> 	<Logger name="org.springframework" level="warn">
> 		</Logger>
> 		<Logger name="io.netty" level="warn">
> 		</Logger>
> 		<Logger name="org.apache.http" level="warn">
> 		</Logger>
> 		<Logger name="org.apache.commons" level="warn">
> 		</Logger>
> 		<Logger name="com.mchange.v2" level="warn">
> 		</Logger>
> 		<Logger name="java.sql" level="warn">
> 		</Logger>
> 		<!-- Game Stat  logger -->
> 		<Logger name="com.lingyu.game.service.log.lingyu" level="info" additivity="false">
> 		<appender-ref ref="LingyuLog" />
> 		</Logger>
> 		<!-- Root Logger -->
> 		<Root level="DEBUG" includeLocation="false">
> 		<appender-ref ref="DevLog" />
> 		<appender-ref ref="Console"/>
> 		</Root>
> 	</loggers>
> </configuration>
> {code}
> and log4j2.component.properties content:
> Log4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
>  



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message