Log4j memory leak ?

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 ?
Who is Participating?
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..
That seems all quite natural...
dannyshAuthor Commented:
>> 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 ?
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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.:

What kind of rolling log is yours....

Is it time roll over or size roll over..
>>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 ;-))
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.