Solved

Log4j memory leak ?

Posted on 2004-04-26
6
1,532 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse compiler vs Installed JREs option 3 76
printing a file in reverse order is easy in recursion rather than in iteration 3 51
table example 4 22
javap not working 8 36
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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 will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

910 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now