Printing Related Memory Leaks in 2.0.7 - Patches Attached

Richard Bollinger rabollinger at home.com
Sat Nov 18 20:19:55 GMT 2000


We were about to upgrade from Samba version 2.0.5a to 2.0.7 on our Solaris
2.6+ servers when we noticed an much larger memory footprint for both the
master and child smbd processes with 2.0.7 as compared with the older
release.  The base process size went from less than 4mb to almost 16mb; and
that bloat passed onto every child process created, rapidly consuming the
limited virtual memory on our test server.  FYI, we compiled each version
with GCC version 2.7.2.3 (old but normally reliable).

Further investigation and activiation of the dormant MEM_MAN facility
revealed that the "talloc" storage used during smb.conf processing was not
being freed at all in the master smbd process and that it grew wildly during
parsing of our long printcap file for the [printers] share.  The use of
talloc in lp_string() was one of the changes announced in version 2.0.7 (
http://us1.samba.org/samba/whatsnew/samba-2.0.7.html ).

The pattern appeared to be non-linear with respect to the length of the
printcap file; that is, more memory was consumed by each printer definition
as the file was processed.  Our printcap file has about 280 entries.

Also, the symptom does not occur if we replace the [printers] entry with all
of the corresponding individual printer share stanzas.

The attached file "fixleaks.patch" includes a prior memory leak fix along
with two new calls to lp_talloc_free() in smbd/server.c/opensockets() and
param/loadparm.c/lp_add_one_printer().  With these changes, the base memory
requirement for version 2.0.7 is close to that of 2.0.5a.

Its strange that these changes do not seem to be necessary for the Linux
operating environment, even with the same printer configuration.  Perhaps
there is a subtle endian bug lurking in there causing the extra memory
allocations?

In case someone else wants to follow the same path, I've attached another
file, "mem_man.patch", which enables and fine tunes the memory debugging
facility included in the CVS source files of 2.0.7 in the source/mem_man
directory.  This patch can be applied before running ./configure in the
source directory in order to enable the memory debugging facility.  With
this facility, a detailed report of memory allocation may be printed to the
log file at any time by sending a USR1 signal to the process with a
"kill -USR1 <pid>" command.

Rich Bollinger, Elliott Company
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fixleaks.patch
Type: application/octet-stream
Size: 1456 bytes
Desc: not available
Url : http://lists.samba.org/archive/samba-technical/attachments/20001118/b4b36064/fixleaks.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mem_man.patch
Type: application/octet-stream
Size: 3392 bytes
Desc: not available
Url : http://lists.samba.org/archive/samba-technical/attachments/20001118/b4b36064/mem_man.obj


More information about the samba-technical mailing list