Re: Squid 2.4-200105082300 memory leaks

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Wed, 09 May 2001 21:02:13 +0200

Running purify in normal leak finding mode is not of very much help for
finding memory leaks in Squid as Squid does not even attempt to clean up
most data on shutdown. To get any useful data you need to compare with a
"normal" leak report.

If you think there is a memory leak then first thing you should check is
the "Memory utilisation" page in cachemgr. Most leaks show up there as
well.. (look for entries where "allocated high hours" is close to 0).

Next, if the leak does not seem to be reflected in the "Memory
utlisation" page, then you most likely need a malloc debugger with "heap
snapshots" (or whatever to call it.. being able to show the memory
allocation differences over time in a running process). A malloc
debugger that can run the leak check on a running process is sometimes
sufficient, but most times Squid has references to "leaked" memory, only
that it does not know how to access these references..

Events where I take for granted there are real memory leaks:

a) Log rotation

b) Reconfigure

--
Henrik Nordstrom
Squid hacker
John Gilbert wrote:
> 
> Dear All,
> Florin Andrei and myself have been using squid 2.4 as SGI's main web
> proxy for the last two months, and have been seeing some bad behavior.
> Thinking that this is most likely due to a memory leek, I ran squid under
> purify and found some serious problems. I'm forwarding the log file
> generated with the latest 2.4 squid in the hopes that you can review and
> correct some of these problems. Purify considers a Memory Leak as
> allocated memory without any pointers remaining to it, so it is
> unretreavable. A potential memory leak is one that has a pointer to it
> but not at the beginning of the allocated memory.  This test was done
> using a single client hitting only three different web pages through a
> small test proxy that goes through our default proxy. Our main web proxy
> has roughly three thousand users and an average load during business
> hours of one hundred hits per second. Please help. Thanks in advance.
> John Gilbert
> jgilbert@sgi.com
> Florin Andrei
> florin@sgi.com
> 
>     ---------------------------------------------------------------
> ****  Purify instrumented squid.pure (pid 42675 at Wed May  9 10:01:11 2001)
>   * Purify 5.3 IRIX6, Copyright (C) 1992-2000 Rational Software Corp. All rights reserved.
>   * For contact information type: "purify -help"
>   * For TTY output, use the option "-windows=no"
>   * Command-line: squid.pure -NY
>   * Options settings: -purify -purify-home=/opt/releases/purify-5.3-irix6
>   * License successfully checked out.
> 
> ****  Purify instrumented squid.pure (pid 42675)  ****
> SIG: Signal handled:
>   * This is occurring while in:
>         __poll         [poll.s:20]
>         _poll          [syscalls.c:7964]
>         comm_poll      [comm_select.c:381]
>         main           [main.c:720]
>         __start        [crt1text.s:176]
>   * Received signal 15 (SIGTERM - Terminated)
>   * Handler function:
>         shut_down      [main.c:266]
>   * Signal mask:
>   * Pending signals:
> 
> ****  Purify instrumented squid.pure (pid 42675)  ****
> Current file descriptors in use: 4
> FIU: file descriptor 26: <reserved for Purify internal use>
> FIU: file descriptor 27: <reserved for Purify internal use>
> FIU: file descriptor 45: <unnamed pipe[1]>, O_RDWR
>    * This file descriptor was allocated from:
>         _pipe          [syscalls.c:7808]
>         ipcCreate      [ipc.c:118]
>         storeDiskdDirInit [store_dir_diskd.c:418]
>         storeDirInit   [store_dir.c:65]
>         storeInit      [store.c:937]
>         mainInitialize [main.c:515]
> FIU: file descriptor 48: <unnamed pipe[1]>, O_RDWR
>    * This file descriptor was allocated from:
>         _pipe          [syscalls.c:7808]
>         ipcCreate      [ipc.c:118]
>         storeDiskdDirInit [store_dir_diskd.c:418]
>         storeDirInit   [store_dir.c:65]
>         storeInit      [store.c:937]
>         mainInitialize [main.c:515]
> 
> ****  Purify instrumented squid.pure (pid 42675)  ****
> Purify: Searching for all memory leaks...
> 
> Memory leaked: 320748 bytes (6.61%); potentially leaked: 50316 bytes (1.04%)
> 
> MLK: 212992 bytes leaked in 26 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         helperOpenServers [helper.c:102]
>   * Block of 8192 bytes (26 times); last block at 0x10345728
> 
> MLK: 24576 bytes leaked in 3 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         httpProcessReplyHeader [http.c:330]
>   * Block of 8192 bytes (3 times); last block at 0x10792f38
> 
> MLK: 23280 bytes leaked in 20 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         requestCreate  [HttpRequest.c:41]
>   * Block of 1164 bytes (20 times); last block at 0x1072f058
> 
> MLK: 16384 bytes leaked in 4 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         httpAccept     [client_side.c:2905]
>   * Block of 4096 bytes (4 times); last block at 0x107508e8
> 
> MLK: 12288 bytes leaked in 3 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         clientWriteComplete [client_side.c:1944]
>   * Block of 4096 bytes (3 times); last block at 0x10759b18
> 
> MLK: 8192 bytes leaked in 2 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         clientCreateStoreEntry [client_side.c:209]
>   * Block of 4096 bytes (2 times); last block at 0x10756738
> 
> MLK: 4096 bytes leaked at 0x107104d8
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         mimeLoadIconFile [mime.c:437]
> 
> MLK: 4096 bytes leaked at 0x1076bfa0
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         httpReplyParse [HttpReply.c:146]
> 
> MLK: 3920 bytes leaked in 5 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         parseHttpRequest [client_side.c:2376]
>   * Block of 784 bytes (5 times); last block at 0x107cc440
> 
> MLK: 3072 bytes leaked in 6 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocBuf    [mem.c:154]
>         stringInitBuf  [String.c:41]
>   * Block of 512 bytes (6 times); last block at 0x107582d0
> 
> MLK: 2560 bytes leaked in 32 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         helperOpenServers [helper.c:96]
>   * Block of 80 bytes (32 times); last block at 0x10345610
> 
> MLK: 1344 bytes leaked in 21 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         storeDiskdCreate [store_io_diskd.c:130]
>   * Block of 64 bytes (21 times); last block at 0x107310c0
> 
> MLK: 636 bytes leaked in 3 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         aclChecklistCreate [acl.c:1814]
>   * Block of 212 bytes (3 times); last block at 0x107426c0
> 
> MLK: 608 bytes leaked in 4 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         httpAccept     [client_side.c:2897]
>   * Block of 152 bytes (4 times); last block at 0x107507f8
> 
> MLK: 384 bytes leaked in 32 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         comm_add_close_handler [comm.c:657]
>         helperOpenServers [helper.c:120]
>   * Block of 12 bytes (32 times); last block at 0x10347780
> 
> MLK: 360 bytes leaked in 5 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         statHistInit   [StatHist.c:74]
>         statHistEnumInit [StatHist.c:285]
>         statCountersInitSpecial [stat.c:985]
>   * Block of 72 bytes (5 times); last block at 0x104e5870
> 
> MLK: 288 bytes leaked in 4 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         storeClientListAdd [store_client.c:136]
>   * Block of 72 bytes (4 times); last block at 0x10756698
> 
> MLK: 252 bytes leaked in 21 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         storeDiskdCreate [store_io_diskd.c:132]
>         storeCreate    [store_io.c:48]
>   * Block of 12 bytes (21 times); last block at 0x1072ecc0
> 
> MLK: 220 bytes leaked in 5 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         httpStart      [http.c:902]
>   * Block of 44 bytes (5 times); last block at 0x107b9718
> 
> MLK: 152 bytes leaked in 2 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         errorCon       [errorpage.c:239]
>   * Block of 76 bytes (2 times); last block at 0x1078ddc0
> 
> MLK: 144 bytes leaked in 12 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         peerAddFwdServer [peer_select.c:648]
>   * Block of 12 bytes (12 times); last block at 0x10757868
> 
> MLK: 120 bytes leaked at 0x107425f0
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         peerSelect     [peer_select.c:137]
> 
> MLK: 112 bytes leaked in 2 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         commConnectStart [comm.c:234]
>         fwdConnectStart [forward.c:310]
>   * Block of 56 bytes (2 times); last block at 0x10757928
> 
> MLK: 84 bytes leaked in 21 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         storeSwapOutStart [store_swapout.c:64]
>   * Block of 4 bytes (21 times); last block at 0x1071c330
> 
> MLK: 64 bytes leaked in 2 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         comm_write     [comm.c:878]
>         clientSendMoreData [client_side.c:1769]
>   * Block of 32 bytes (2 times); last block at 0x10763ad8
> 
> MLK: 60 bytes leaked in 5 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         comm_add_close_handler [comm.c:657]
>         commConnectStart [comm.c:243]
>   * Block of 12 bytes (5 times); last block at 0x1083e9c0
> 
> MLK: 56 bytes leaked at 0x10303a88
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         helperCreate   [helper.c:227]
> 
> MLK: 56 bytes leaked at 0x1083e8c8
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         commConnectStart [comm.c:234]
>         sslPeerSelectComplete [ssl.c:598]
> 
> MLK: 48 bytes leaked in 4 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         comm_add_close_handler [comm.c:657]
>         httpAccept     [client_side.c:2907]
>   * Block of 12 bytes (4 times); last block at 0x10740220
> 
> MLK: 48 bytes leaked in 3 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         storeSwapTLVAdd [store_swapmeta.c:41]
>   * Block of 16 bytes (3 times); last block at 0x107116d8
> 
> MLK: 48 bytes leaked at 0x10733c08
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         storeDiskdDirSwapLog [store_dir_diskd.c:1284]
> 
> MLK: 48 bytes leaked in 4 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         comm_add_close_handler [comm.c:657]
>         fwdConnectStart [forward.c:305]
>   * Block of 12 bytes (4 times); last block at 0x107578c8
> 
> MLK: 32 bytes leaked at 0x10733c90
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         file_write     [disk.c:307]
> 
> MLK: 32 bytes leaked at 0x10742cf8
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         comm_write     [comm.c:878]
>         helperDispatch [helper.c:398]
> 
> MLK: 32 bytes leaked at 0x10748ad0
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         pconnNew       [pconn.c:75]
>         pconnPush      [pconn.c:205]
> 
> MLK: 32 bytes leaked at 0x10769750
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         comm_write     [comm.c:878]
>         comm_write_mbuf [comm.c:893]
> 
> MLK: 20 bytes leaked at 0x107262a0
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         pconnNew       [pconn.c:72]
>         pconnPush      [pconn.c:205]
> 
> MLK: 12 bytes leaked at 0x10742c30
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         helperSubmit   [helper.c:130]
> 
> PLK: 49152 bytes potentially leaked in 6 blocks
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         helperOpenServers [helper.c:102]
>   * Block of 8192 bytes (6 times); last block at 0x10341388
> 
> PLK: 1164 bytes potentially leaked at 0x1071dd60
>   * This memory was allocated from:
>         _malloc        [malloc.c:966]
>         _calloc        [malloc.c:2048]
>         xcalloc        [util.c:562]
>         memPoolAlloc   [MemPool.c:250]
>         memAllocate    [mem.c:127]
>         requestCreate  [HttpRequest.c:41]
> 
> Purify Heap Analysis (combining suppressed and unsuppressed blocks)
>                          Blocks        Bytes
>               Leaked        263       320748
>   Potentially Leaked          7        50316
>               In-Use       7466      4482102
>   ----------------------------------------
>      Total Allocated       7736      4853166
> 
> ****  Purify instrumented squid.pure (pid 42675)  ****
>   * Program exited with status code 0.
>   * 1 access error, 1 total occurrence.
>   * 320748 bytes leaked.
>   * 50316 bytes potentially leaked.
>   * Basic memory usage (including Purify overhead):
>     2015232 code
>     1410276 data/bss
>     6732572 heap (peak use)
>     4464 stack
>   * Shared library memory usage (including Purify overhead):
>     413696 rtlib_n32.so (shared code)
>     67620 rtlib_n32.so (private data)
>     32768 libcrypt.so.00017064d5e0.pure (shared code)
>     4056 libcrypt.so.00017064d5e0.pure (private data)
>     491520 libm.so.000151df53cf.pure (shared code)
>     98320 libm.so.000151df53cf.pure (private data)
>     32768 libmalloc.so.0001d772a771.pure (shared code)
>     304 libmalloc.so.0001d772a771.pure (private data)
>     2523136 libc.so.1.0000c2be8cb5.pure (shared code)
>     76272 libc.so.1.0000c2be8cb5.pure (private data)
>   * Memory mapped usage:
>     524288 mmap'd at 0x4b51000
>     524288 mmap'd at 0x4a71000
>     1921024 mmap'd at 0x483c000
>     4190208 mmap'd at 0x4268000
>     8192 mmap'd at 0x4809000
Received on Wed May 09 2001 - 13:06:32 MDT

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