[Asterisk-bugs] [Asterisk 0010133]: Large memory leak in dns.c:ast_search_dns()

noreply at bugs.digium.com noreply at bugs.digium.com
Fri Jul 6 10:05:24 CDT 2007


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=10133 
====================================================================== 
Reported By:                scw
Assigned To:                qwell
====================================================================== 
Project:                    Asterisk
Issue ID:                   10133
Category:                   Addons/General
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     assigned
Asterisk Version:           1.4.6 
SVN Branch (only for SVN checkouts, not tarball releases): N/A  
SVN Revision (number only!):  
Disclaimer on File?:        No 
Request Review:              
====================================================================== 
Date Submitted:             07-06-2007 01:49 CDT
Last Modified:              07-06-2007 10:05 CDT
====================================================================== 
Summary:                    Large memory leak in dns.c:ast_search_dns()
Description: 
On NetBSD (and almost certainly others), each call to ast_search_dns() will
leak more than 800 bytes of memory. This is particularly noticeable with
several "register" entries in sip.conf and a short registration interval,
where the asterisk process can consume 5-6MB of leaked memory in a 24 hour
period.

When HAS_RES_NINIT is defined, ast_search_dns() invokes res_ninit() to
initialise a local dnsstate variable. This variable is then used during
nameserver lookups in res_search(). On completion, ast_search_dns() calls
res_nclose() in an attempt to clean up.

Unfortunately, with NetBSD's BIND-based resolver (and probably any other
OS using the same BIND code, like FreeBSD), res_nclose() doesn't free all
state. Instead, ast_search_dns() must invoke res_ndestroy() to ensure all
state is freed. Note that res_ndestroy() does an implicit res_nclose(), so
simply replacing the call to res_nclose() with res_ndestroy() will do the
right thing.




====================================================================== 

---------------------------------------------------------------------- 
 qwell - 07-06-07 10:05  
---------------------------------------------------------------------- 
Try these patches..  Do they seem right? 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
07-06-07 10:05  qwell          Note Added: 0066592                          
======================================================================




More information about the Asterisk-bugs mailing list