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

Remko Popma commented on LOG4J2-1167:
-------------------------------------

This is not necessarily a memory leak. Does memory usage only go up and never 
go down, or does it go down during quiet periods? 

If you log a lot, it is possible that the Console appender is slow and falls 
behind, filling up the ring buffer. You can verify this in JConsole by looking 
at the AsyncLoggerRingBuffer JMX MBean and checking the RemainingCapacity. I 
suspect this will be very low at the time when your memory usage is high.

If this is true, you can try sending fewer log events to the Console by 
configuring like this:
{code}
<Root level="DEBUG" includeLocation="false">
  <appender-ref ref="DevLog" />
  <appender-ref ref="Console" level="INFO"/>
</Root>
{code}


> 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to