|
From: Christian P. <tr...@ge...> - 2005-08-26 01:21:26
|
Hi all, my daemon running on a production server having lots of I/O a day is=20 eating the RAM really wastinly. Well, of course, it'ms my fault, somehow, but I didn't manage to get rid of all of them _yet_. Two of the memory leaks I reproduced using valgrind are as follows: =3D=3D16981=3D=3D 84 bytes in 3 blocks are still reachable in loss record 1= 1 of 28 =3D=3D16981=3D=3D at 0x1B9008C1: malloc (vg_replace_malloc.c:149) =3D=3D16981=3D=3D by 0x1D87B205: ??? =3D=3D16981=3D=3D by 0x1D87A1A9: ??? =3D=3D16981=3D=3D by 0x1D87A457: ??? =3D=3D16981=3D=3D by 0x1D87A950: ??? =3D=3D16981=3D=3D by 0x1D86F2CD: ??? =3D=3D16981=3D=3D by 0x1D86F5DA: ??? =3D=3D16981=3D=3D by 0x1D20ADFF: gethostbyname2_r (in /lib/libc-2.3.5.so) =3D=3D16981=3D=3D by 0x1D20ABCB: gethostbyname2 (in /lib/libc-2.3.5.so) =3D=3D16981=3D=3D by 0x1C39406B: System::Network::THostAddress::fromHost= Name(System::TStringBase<char> const&, System::Network::THostAddress::TFami= ly) (Utils.cp =3D=3D16981=3D=3D by 0x1CB5E371: htutils::hasIP(System::TStringBase<char= > const&) (htutils.cpp:102) =3D=3D16981=3D=3D by 0x1CB5F3AA: htutils::htmlFormat(System::TStringBase= <char> const&) (htutils.cpp:446) =3D=3D16981=3D=3D by 0x1CB92A5A: yacs::TMessageFormatter::formatChatCode= (System::TStringBase<char> const&) (TMessageFormatter.cpp:54) =3D=3D16981=3D=3D by 0x1CB94CCD: System::TFunctorHandler<System::TFuncto= r<System::TStringBase<char>, System::TTypeList<System::TStringBase<char> co= nst&, System: =3D=3D16981=3D=3D by 0x1CB93246: System::TFunctor<System::TStringBase<ch= ar>, System::TTypeList<System::TStringBase<char> const&, System::NullType> = >::operator() =3D=3D16981=3D=3D by 0x1CB92428: yacs::TBasicMessageFormatter::formatMes= sage(System::TStringBase<char> const&, System::TStringBase<char> const&) (T= MessageFormat =3D=3D16981=3D=3D by 0x1CB929F9: yacs::TMessageFormatter::format(System:= :TStringBase<char> const&, System::TStringBase<char> const&) (TMessageForma= tter.cpp:50) =3D=3D16981=3D=3D by 0x1D5B7204: ??? =3D=3D16981=3D=3D by 0x1D5BE701: ??? =3D=3D16981=3D=3D by 0x1BA7F18D: System::TFunctor<void, System::TTypeLis= t<yacs::TNetClientSession&, System::TTypeList<System::TDynamicArray<System:= :TStringBase< =3D=3D16981=3D=3D by 0x1BA6F471: yacs::TServer::handleCmd(yacs::TNetClie= ntSession*, System::TStringBase<char> const&, System::TDynamicArray<System:= :TStringBase< =3D=3D16981=3D=3D by 0x1BA56F73: yacs::TNetClientSession::handleInput() = (TNetClientSession.cpp:109) =3D=3D16981=3D=3D by 0x1BA56D24: yacs::TNetClientSession::onInput(System= ::Network::TNetworkStream*) (TNetClientSession.cpp:85) =3D=3D16981=3D=3D by 0x1BA5BAEA: System::TMemFunHandler<System::TFunctor= <void, System::TTypeList<System::Network::TNetworkStream*, System::NullType= > >, yacs::TN =3D=3D16981=3D=3D by 0x1C393206: System::TFunctor<void, System::TTypeLis= t<System::Network::TNetworkStream*, System::NullType> >::operator()(System:= :Network::TNe =3D=3D16981=3D=3D by 0x1C39276A: System::Network::TNetworkStreamPrivate:= :onDataAvailableNow(int, System::IO::Unix::TPollMask) (TNetworkStreamPrivat= e.cpp:160) =3D=3D16981=3D=3D by 0x1C393873: System::TMemFunHandler<System::TFunctor= <void, System::TTypeList<int, System::TTypeList<System::IO::Unix::TPollMask= , System::Nul =3D=3D16981=3D=3D by 0x1C35F03D: System::TFunctor<void, System::TTypeLis= t<int, System::TTypeList<System::IO::Unix::TPollMask, System::NullType> > >= ::operator()( =3D=3D16981=3D=3D by 0x1C367356: System::IO::Unix::TPollMgr::TInterest::= notify(System::IO::Unix::TPollMask) (TPollMgr.cpp:232) =3D=3D16981=3D=3D by 0x1C36708A: System::IO::Unix::TPollMgr::processPend= ing() (TPollMgr.cpp:193) =3D=3D16981=3D=3D by 0x1C366DEF: System::IO::Unix::TPollMgr::dispatchOnc= e(System::TTimeSpan) (TPollMgr.cpp:139) =3D=3D16981=3D=3D by 0x1BA6E07E: yacs::TServer::run() (TServer.cpp:383) =3D=3D16981=3D=3D by 0x8064F38: serve(System::TVarData const&) (yacsd.cp= p:326) =3D=3D16981=3D=3D by 0x80667C7: main (yacsd.cpp:412) Interestingly, the man-page doesn't tell me anything about=20 gethostbyname_r() to be free()d afterwards. So, I don't=20 understand in why it leaks there. However, this does not lead me into blindly assuming,=20 that it's glibc's fault here. But what could be wrong there? And this is another odd one: =3D=3D16981=3D=3D 4088 bytes in 1 blocks are still reachable in loss record= 22 of 28 =3D=3D16981=3D=3D at 0x1B9008C1: malloc (vg_replace_malloc.c:149) =3D=3D16981=3D=3D by 0x1CCF63BD: my_once_alloc (in /usr/lib/libmysqlclie= nt_r.so.14.0.0) =3D=3D16981=3D=3D by 0x1CCF6466: my_once_strdup (in /usr/lib/libmysqlcli= ent_r.so.14.0.0) =3D=3D16981=3D=3D by 0x1CCF7021: (within /usr/lib/libmysqlclient_r.so.14= =2E0.0) =3D=3D16981=3D=3D by 0x1CCFFF78: (within /usr/lib/libmysqlclient_r.so.14= =2E0.0) =3D=3D16981=3D=3D by 0x1CD1026D: my_xml_parse (in /usr/lib/libmysqlclien= t_r.so.14.0.0) =3D=3D16981=3D=3D by 0x1CD004DA: my_parse_charset_xml (in /usr/lib/libmy= sqlclient_r.so.14.0.0) =3D=3D16981=3D=3D by 0x1CCF6A10: (within /usr/lib/libmysqlclient_r.so.14= =2E0.0) =3D=3D16981=3D=3D by 0x1CCF6C8F: (within /usr/lib/libmysqlclient_r.so.14= =2E0.0) =3D=3D16981=3D=3D by 0x1CCF76B8: get_charset_by_csname (in /usr/lib/libm= ysqlclient_r.so.14.0.0) =3D=3D16981=3D=3D by 0x1CD1504B: mysql_real_connect (in /usr/lib/libmysq= lclient_r.so.14.0.0) =3D=3D16981=3D=3D by 0x1CB4313A: MySQL::connect(System::TStringBase<char= > const&, System::TStringBase<char> const&, System::TStringBase<char> const= &, System::TS =3D=3D16981=3D=3D by 0x1BA704DE: yacs::TServer::createConnection() const= (TServer.cpp:590) =3D=3D16981=3D=3D by 0x1BA70575: yacs::TServer::initializeTables() (TSer= ver.cpp:600) =3D=3D16981=3D=3D by 0x1BA6683E: yacs::TServer::TServer(int, System::TSt= ringBase<char> const&, System::TStringBase<char> const&, System::TStringBas= e<char> const =3D=3D16981=3D=3D by 0x806380C: spawnServer() (yacsd.cpp:281) =3D=3D16981=3D=3D by 0x80659FA: main (yacsd.cpp:388) I'm pretty sure, that mysql_close() gets invoked everywhere, but somehow,=20 libmysqlclient leaks here a memory block regarding its connection establish= ment. Well, I'm linking against the _r version of libmysqlclient, becuase it is s= upposed to be fully multi threaded (some day) and I wanted to be on the safe side, but I don't think that this is *causing* the leak. And yet, I do not understand in why this is happening here :( I'd welcome any kinda hints, thanks in advance, Christian Parpart. |