Solved

Log4j memory leak ?

Posted on 2004-04-26
6
1,554 Views
Last Modified: 2007-12-19
Hi all
We are using log4j version 1.2.8.
Our configuration is 10 rolling log files for each of the following debug,error and trace, each file size is 20M.
The problem is that the memory consumption grows directly with the logs grows.
I have system with 1G memory, starting the application the memory consumption is 100M and when
all 30 files (debug,error and trace) were full I checked the memory and it was ~700M used.
I delete 27 files (debg.log.x , error.log.x and trace.log.x) and the memory decreased back to 100M.
How come ? any idea ? we wrap the log4j in our project , anything we should take of when wraping it ?
0
Comment
Question by:dannysh
  • 3
  • 2
6 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 10917121
That seems all quite natural...
0
 
LVL 9

Accepted Solution

by:
mmuruganandam earned 50 total points
ID: 10917149
You have something called FileAppender.  Write your own FileAppender by extending the FileAppender class.

There you have few controls on closing the files and few..
0
 

Author Comment

by:dannysh
ID: 10917166
>> That seems all quite natural
What do u mean ? should it be like that ?

>>You have something called FileAppender.  Write your own FileAppender by extending the FileAppender

How they implemnt it ? do they keep all lojs in memory also ? any idea where can I find implemenmation for it ?
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 86

Expert Comment

by:CEHJ
ID: 10917168
If you want to limit the size to which your files grow (and it sounds like you might do) you don't need to subclass a FileAppender to do this - the max file size is a configurable property that you can change in your config file, e.g.:

log4j.appender.A1.MaxFileSize=300KB
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10917186
What kind of rolling log is yours....

Is it time roll over or size roll over..
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10917202
>>What do u mean ? should it be like that ?

What i mean is that it doesn't surprise me. I'd take a guess that to avoid a bad performance hit due to continually opening and closing files, they've avoided a simple append to the log file by normal io means of appending, by buffering. As the files grow in size, the buffer may well do too. (Just a guess ;-))
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
factorial example 4 41
expectj telnet failing 5 38
spring jars download 1 29
jsp login check 12 32
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question