This describes a way to write a script using GTop to print out the memory usage of teh process.
Set your dev machine to use only one process, restart, then go through your scripts one by one to see who grows when you run them.
I got it down to the script level like this. I haven't yet found the leaks in those scripts.
You can configure apache to resart the process after so many pages are served, this stops the leak from bringing down teh server. If the leak is not too huge (mine were 50k or less) this can help you with damage control, short term.
As for finding the source of the leak within a script - I'm interested in what others have to say. Commenting out blocks of code to track it by elimination is my best idea so far. Maybe there are better ways.
cheers
D
On 2/10/06, Jens Gassmann <[EMAIL PROTECTED]> wrote:
Hi,
our new development-server run into out of memory and use more then 2GB
Ram. How could i determine the process who is responsible for this
memory leak?
Server version: Apache/2.0.55
Server built: Jan 24 2006 15:02:24
Server's Module Magic Number: 20020903:11
Architecture: 64-bit
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D HTTPD_ROOT="/usr"
-D SUEXEC_BIN="/usr/sbin/suexec2"
-D DEFAULT_PIDLOG="/var/run/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="/var/run/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="/etc/apache2/mime.types"
-D SERVER_CONFIG_FILE="/etc/apache2/httpd.conf"
Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
Platform:
osname=linux, osvers=2.6.15-gentoo-r1-amd64, archname=x86_64-linux
uname='linux avila 2.6.15-gentoo-r1-amd64 #1 wed jan 18 16:33:48
cet 2006 x86_64 amd athlon(tm) 64 processor 3500+ authenticamd gnulinux '
config_args='-des -Darchname=x86_64-linux -Dcccdlflags=-fPIC
-Dccdlflags=-rdynamic -Dcc=x86_64-pc-linux-gnu-gcc -Dprefix=/usr
-Dvendorprefix=/usr -Dsiteprefix=/usr -Dlocincpth= -Doptimize=-O2
-march=k8 -pipe -Duselargefiles -Dd_semctl_semun -Dscriptdir=/usr/bin
-Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3
-Dinstallman1dir=/usr/share/man/man1
-Dinstallman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3pm
-Dinc_version_list=5.8.0 5.8.0/x86_64-linux 5.8.2 5.8.2/x86_64-linux
5.8.4 5.8.4/x86_64-linux 5.8.5 5.8.5/x86_64-linux 5.8.6
5.8.6/x86_64-linux -Dcf_by=Gentoo -Ud_csh -Ui_ndbm -Ui_gdbm -Di_db
-Dusrinc=/usr/include/gentoo-multilib/amd64 -Dlibpth='/usr/local/lib64
/lib64 /usr/lib64''
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=define use64bitall=define uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='x86_64-pc-linux-gnu-gcc', ccflags ='-fno-strict-aliasing -pipe
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2 -march=k8 -pipe',
cppflags='-fno-strict-aliasing -pipe'
ccversion='', gccversion='3.4.4 (Gentoo 3.4.4-r1, ssp-3.4.4-1.0,
pie-8.7.8)', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='x86_64-pc-linux-gnu-gcc', ldflags =''
libpth=/usr/local/lib64 /lib64 /usr/lib64
libs=-lpthread -lnsl -ldb -ldl -lm -lcrypt -lutil -lc
perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.3.5.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.3.5'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fPIC', lddlflags='-shared'
Characteristics of this binary (from libperl):
Compile-time options: USE_64_BIT_INT USE_64_BIT_ALL USE_LARGE_FILES
Built under linux
Compiled at Jan 18 2006 17:11:51
@INC:
/etc/perl
/usr/lib/perl5/site_perl/5.8.7/x86_64-linux
/usr/lib/perl5/site_perl/5.8.7
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.7/x86_64-linux
/usr/lib/perl5/vendor_perl/5.8.7
/usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.7/x86_64-linux
/usr/lib/perl5/5.8.7
/usr/local/lib/site_perl
Portage 2.0.54 (default-linux/amd64/2005.1, gcc-3.4.4, glibc-2.3.5-r2,
2.6.15-gentoo-r1-amd64 x86_64)
=================================================================
System uname: 2.6.15-gentoo-r1-amd64 x86_64 AMD Athlon(tm) 64 Processor
3500+
Gentoo Base System version 1.6.14
dev-lang/python: 2.3.5-r2, 2.4.2
sys-apps/sandbox: 1.2.12
sys-devel/autoconf: 2.13, 2.59-r6
sys-devel/automake: 1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r1
sys-devel/binutils: 2.16.1
sys-devel/libtool: 1.5.22
virtual/os-headers: 2.6.11-r2
ACCEPT_KEYWORDS="amd64"
AUTOCLEAN="yes"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -march=k8 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3/share/config
/usr/share/config /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-O2 -march=k8 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig distlocks sandbox sfperms strict"
GENTOO_MIRRORS="http://distfiles.gentoo.org
http://distro.ibiblio.org/pub/linux/distributions/gentoo"
LANG="[EMAIL PROTECTED]"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="amd64 acl alsa apache2 avi berkdb bitmap-fonts bzip2 crypt eds
emboss encode expat foomaticdb fortran gif gpm gstreamer gtk2
imagemagick imlib ipv6 jpeg libwww lzw lzw-tiff mhash mp3 mpeg mysql
ncurses nls no-suexec odbc opengl pam pcre pdflib perl php png python
quicktime readline samba sdl spell ssl tcpd tiff truetype truetype-fonts
type1-fonts udev urandom usb userlocales xpm xv zlib userland_GNU
kernel_linux elibc_glibc"
Unset: ASFLAGS, CTARGET, LC_ALL, LDFLAGS, LINGUAS
--
Daniel McBrearty
email : danielmcbrearty at gmail.com
www.engoi.com : the multi - language vocab trainer
BTW : 0873928131