Re: patches for a few memory leaks

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Mon, 28 May 2001 01:51:54 +0200

Radu Greab wrote:

> 1. Squid leaks 72 bytes every minute because it does not free data
> allocated for comm_dns_incoming counter:

Applied.

> 2. snmpAddNode() duplicates the oid created by snmpCreateOid() and
> does not free the original. A few bytes leaked at start-up.

Applied. Knew about the leak, but had not made up my mind on how to fix
it. Your patch is as good as any.

> 3. If Squid is configured as a httpd accelerator, then it leaks
> Config2.Accel.prefix at every reconfigure/log rotation. I moved the
> initialization and the memory freeing code into cf_gen.c. The
> code will be put into the generated default_all() and
> free_all(). Is this the right approach?

Hmm.. don't like this approach. Config2 is runtime derived
configuration, not driven by cf.data.

Fixed in configFreeMemory instead, and changed parseConfigFile to call
this instead of free_all.

> 4. If squid is compiled with support for delay pools but no pools are
> configured, then squid will leak a few bytes at every
> reconfigure/log rotation.

Please explain. This piece of code (parse_delay_pool_count) is only
called if you configure delay pools, and the allocated data seems to be
freed properly.

> --- squid-2.4.STABLE1/src/cache_cf.c.orig Thu Mar 1 23:49:25 2001
> +++ squid-2.4.STABLE1/src/cache_cf.c Thu May 24 02:40:42 2001
> @@ -682,10 +682,12 @@
> free_delay_pool_count(cfg);
> }
> parse_ushort(&cfg->pools);
> - delayInitDelayData(cfg->pools);
> - cfg->class = xcalloc(cfg->pools, sizeof(u_char));
> - cfg->rates = xcalloc(cfg->pools, sizeof(delaySpecSet *));
> - cfg->access = xcalloc(cfg->pools, sizeof(acl_access *));
> + if (cfg->pools) {
> + delayInitDelayData(cfg->pools);
> + cfg->class = xcalloc(cfg->pools, sizeof(u_char));
> + cfg->rates = xcalloc(cfg->pools, sizeof(delaySpecSet *));
> + cfg->access = xcalloc(cfg->pools, sizeof(acl_access *));
> + }
> }

--
Henrik
Received on Sun May 27 2001 - 17:58:19 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:14:02 MST