On Tue, 1 Nov 2011 16:42:13 +0700, budsz wrote:
Hallo,
After port cvsup, updating lib, packages and so on. I got something
weird problem, I guess this cause memory leak.
root:~# free
SYSTEM MEMORY SUMMARY:
mem_used: 574558208 ( 547MB) [ 53%] Logically used memory
mem_avail: + 499183616 ( 476MB) [ 46%] Logically available
memory
-------------- ------------ ----------- ------
mem_total: = 1073741824 ( 1024MB) [100%] Logically total memory
root:~# /usr/local/etc/rc.d/squid stop
"mem_used:" back to 23%.
Note that Squid uses memory for a lot of things, most of them in very
large blocks or large number of small blocks. The OS does not account
for memory released.
root:~# valgrind -v --tool=memcheck --leak-check=yes squid
*snip*
==45738== 1 errors in context 2 of 39:
==45738== Mismatched free() / delete / delete []
==45738== at 0x4B9D5: operator delete(void*) (in
/usr/local/lib/valgrind/vgpreload_memcheck-x86-freebsd.so)
==45738== by 0xE0518: std::basic_ostringstream<char,
std::char_traits<char>, std::allocator<char>
>::~basic_ostringstream()
(in /usr/lib/libstdc++.so.6)
==45738== by 0x8091369: Debug::finishDebug() (debug.cc:753)
==45738== by 0x81036FD: PconnModule::PconnModule() (pconn.cc:348)
==45738== by 0x8103739: PconnModule::GetInstance() (pconn.cc:356)
==45738== by 0x8103CDE: PconnPool::PconnPool(char const*)
(pconn.cc:241)
==45738== by 0x80A5C0F:
__static_initialization_and_destruction_0(int, int) (forward.cc:76)
==45738== by 0x80A5C59: global constructors keyed to
_ZN8FwdState15CBDATA_FwdStateE (forward.cc:1464)
==45738== by 0x81ABDD7: ??? (in /usr/local/sbin/squid)
==45738== by 0x804BAD4: ??? (in /usr/local/sbin/squid)
==45738== by 0x804CBB7: (below main) (in /usr/local/sbin/squid)
==45738== Address 0x2e8180 is 0 bytes inside a block of size 180
alloc'd
==45738== at 0x4C0F5: malloc (in
/usr/local/lib/valgrind/vgpreload_memcheck-x86-freebsd.so)
==45738== by 0x81AB1DD: xmalloc (util.c:508)
==45738== by 0x8050DA0: operator new(unsigned int) (SquidNew.h:49)
==45738== by 0x8090C14: Debug::getDebugOut() (debug.cc:735)
==45738== by 0x81036E8: PconnModule::PconnModule() (pconn.cc:348)
==45738== by 0x8103739: PconnModule::GetInstance() (pconn.cc:356)
==45738== by 0x8103CDE: PconnPool::PconnPool(char const*)
(pconn.cc:241)
==45738== by 0x80A5C0F:
__static_initialization_and_destruction_0(int, int) (forward.cc:76)
==45738== by 0x80A5C59: global constructors keyed to
_ZN8FwdState15CBDATA_FwdStateE (forward.cc:1464)
==45738== by 0x81ABDD7: ??? (in /usr/local/sbin/squid)
==45738== by 0x804BAD4: ??? (in /usr/local/sbin/squid)
==45738== by 0x804CBB7: (below main) (in /usr/local/sbin/squid)
==45738==
==45738== ERROR SUMMARY: 39 errors from 39 contexts (suppressed: 0
from 0)
*snip*
Anyone have a clue?
For some reason your compiler is using Squids internal overloaded
definition of new() and failing to use the matching definition for
delete() which is defined in an identical way right next to it. This
could be a problems since they go through two different memory
accounting systems and this will leave Squid allocated RAM counters
forever going upward.
You snipped away the details about RAM impact. Reconstructing from the
trace count and size this appears to only be leaking a total of 7KB.
Somehow it seems there is something else going on.
Amos