Bug 40183 - rotatelogs leaks memory
Summary: rotatelogs leaks memory
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: support (show other bugs)
Version: 2.5-HEAD
Hardware: Sun Solaris
: P3 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: FixedInTrunk, PatchAvailable
: 44783 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-08-03 22:12 UTC by Yen Chang
Modified: 2011-03-06 00:29 UTC (History)
2 users (show)



Attachments
workaround against trunk (1.08 KB, patch)
2008-01-25 15:43 UTC, Takashi Sato
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yen Chang 2006-08-03 22:12:58 UTC
I use rotatelogs utility which comes with apache 2.0.55 to maintain various
logs. For unknown reasons, the process which manages access_log uses lots of
memory. The following is a snapshot of "top" results.  In the production system,
it uses 2.5 G out of total 4 G memory. I suspect there are memory leak in this
program. Please investigate. Thanks.



last pid: 28090;  load averages:  0.01,  0.11,  0.15                           
                                    17:01:08
71 processes:  70 sleeping, 1 on cpu
CPU states: 99.3% idle,  0.0% user,  0.7% kernel,  0.0% iowait,  0.0% swap
Memory: 2048M real, 1340M free, 410M swap in use, 13G swap free

   PID USERNAME THR PRI NICE  SIZE   RES STATE    TIME    CPU COMMAND
 29404 root      69   0   10  136M   79M sleep   33:05  0.00% java
 15073 root       4  58    0   37M   35M sleep    0:23  0.00% rotatelogs
   227 root      20  58    0 9960K 4216K sleep    0:05  0.00% syslogd
 13564 root       3  59    0 6832K 4136K sleep    0:00  0.00% httpd
Comment 1 Joe Orton 2006-12-11 07:00:19 UTC
It looks like the memory use of rotatelogs will be proportional to the number of
times it has re-opened the log file; it needs to be using subpools and clearing
them etc to have constant memory use.  (pools are grrrrreat!)
Comment 2 Takashi Sato 2008-01-25 15:43:33 UTC
Created attachment 21431 [details]
workaround against trunk

make a pool for logfile and clear it in each apr_file_open.
I made this patch in a short glance so there might be better solutions.
Comment 3 Ruediger Pluem 2008-01-28 06:52:28 UTC
IMHO this would SEGFAULT if we fail to open a new logfile and have to reuse the
old one. So I committed a slightly modified version of your patch to trunk as
r615901 (http://svn.apache.org/viewvc?rev=615901&view=rev). Given the typical
frequency of logfile reopenings I guess we can afford the apr_pool_create /
apr_pool_destroy overhead.
Comment 4 Takashi Sato 2008-01-28 07:10:42 UTC
(In reply to comment #3)
> IMHO this would SEGFAULT if we fail to open a new logfile

Exactly. My patch was very random. Thanks for review.
Comment 5 Anurag 2008-11-30 12:07:06 UTC
How can I get this modified rotatelogs.c .I downloaded new snapshot from apache.org for httpd it did not contained this change.
Plz Comment
Thanks
A
Comment 6 Anurag 2008-11-30 12:09:13 UTC
(In reply to comment #5)
> How can I get this modified rotatelogs.c .I downloaded new snapshot from
> apache.org for httpd it did not contained this change.
> Plz Comment
> Thanks
> A
> 

sorry got the file.
Thanks
A
Comment 7 Ruediger Pluem 2008-11-30 13:47:59 UTC
Fixed since 2.2.9.
Comment 8 Ben Reser 2011-03-06 00:29:56 UTC
*** Bug 44783 has been marked as a duplicate of this bug. ***