possible mem leak ?

A

arne

Hi

below is my rather short script that just takes STDIN and logs it to syslog

if I attach this program to apache as my access-log (I know why i do it like
this), after a few days, the process mem-size is 132Meg and above, which is
too big for such a small program.

have i done something wrong? Should I use references somewhere?

*cut*
#!/usr/bin/perl

use strict;

#this is a funny construction, could have said <1 or > 2
if (@ARGV != 1 && @ARGV != 2) {
print "usage: $0 <servicename> <prefix>\n";
exit(1);
}

my $prefix="";
if (@ARGV==2) {
$prefix = $ARGV[1].": ";
}

use Unix::Syslog qw:)macros :subs);

openlog($ARGV[0], LOG_PID, LOG_LOCAL2);
while (<STDIN>) {
syslog(LOG_INFO, $prefix.$_);
}
closelog();
*cut*
 
B

Brian McCauley

arne said:
if I attach this program to apache as my access-log (I know why i do it like
this), after a few days, the process mem-size is 132Meg and above, which is
too big for such a small program.

have i done something wrong? Should I use references somewhere?

I doubt that anything you have done can be blamed.
use Unix::Syslog qw:)macros :subs);

openlog($ARGV[0], LOG_PID, LOG_LOCAL2);
while (<STDIN>) {
syslog(LOG_INFO, $prefix.$_);
}
closelog();

What version of Perl are you using? Older versions tend to leak more.

Another possibility is that the leak is in Unix::Syslog.

Note you are not calling syslog correctly - is should be

syslog(LOG_INFO, "%s%s", $prefix, $_);

I doubt, however, this could explain your leak.
 
A

arne

if I attach this program to apache as my access-log (I know why i do it
like this), after a few days, the process mem-size is 132Meg and above,
which is too big for such a small program.

have i done something wrong? Should I use references somewhere?

I doubt that anything you have done can be blamed.
use Unix::Syslog qw:)macros :subs);

openlog($ARGV[0], LOG_PID, LOG_LOCAL2);
while (<STDIN>) {
syslog(LOG_INFO, $prefix.$_);
}
closelog();

What version of Perl are you using? Older versions tend to leak more.
it is 5.6.0, maybe it's time to upgrade that version :)
Another possibility is that the leak is in Unix::Syslog.

Note you are not calling syslog correctly - is should be

syslog(LOG_INFO, "%s%s", $prefix, $_);

I doubt, however, this could explain your leak.
thx for the notice, will fix it soon (right is right :))

arne
 
B

Ben Morrow

Quoth "arne said:
below is my rather short script that just takes STDIN and logs it to syslog

if I attach this program to apache as my access-log (I know why i do it like
this), after a few days, the process mem-size is 132Meg and above, which is
too big for such a small program.

Use logger(1) instead.

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,161
Messages
2,570,892
Members
47,427
Latest member
HildredDic

Latest Threads

Top