Archived

This forum has been archived. Please start a new discussion on GitHub.

Possible memory leak in Ice 3.4.2 glacier2router executable

Using chat demo server (with plain tcp instead of ssl and DemoGlacier2/NullPermissionsVerifier) and the following test client code, glacier2router start growing in memory size occupation till eating all the memory of the system (Linux ubuntu 10.04 & opensuse 11.4).

/////////////////////////////////////////////////////////////////////////////7

include <Ice/Ice.h>
#include <IceUtil/IceUtil.h>
#include <Glacier2/Glacier2.h>
#include <Chat.hpp>
using namespace std;

int doit(const Ice::CommunicatorPtr& icPtr)
{
Glacier2::RouterPrx routerPrx;
Demo::ChatSessionPrx chatSessionPrx;

try
{
routerPrx = Glacier2::RouterPrx::checkedCast(icPtr->getDefaultRouter());
chatSessionPrx= Demo::ChatSessionPrx::checkedCast(routerPrx->createSession("user", "pwd"));
chatSessionPrx->ice_ping();
chatSessionPrx->destroy();
routerPrx->destroySession();
return 0;
}
catch (const Ice::Exception& ex)
{
cerr << "Glacier Connection Failed with " << ex.ice_name() << endl;
return -1;
}
}

int main(int argc, char* argv[])
{
Ice::CommunicatorPtr icPtr;
icPtr = Ice::initialize(argc, argv);
unsigned long counter(0);
for(;;++counter)
{
if(doit(icPtr))
exit(-10);

usleep(500);
if (!(counter % 100))
cout << "Counter : " << counter << endl;
}

return 0;
}

////////////////////////////////////////////////////////////////////////////////////////

Running glacier2router with valgrind --leak-check=full doing only one iteration of the test client showed this is the result:

==2004== LEAK SUMMARY:
==2004== definitely lost: 384 bytes in 2 blocks
==2004== indirectly lost: 11,324 bytes in 56 blocks
==2004== possibly lost: 1,691 bytes in 33 blocks
==2004== still reachable: 2,680 bytes in 25 blocks
==2004== suppressed: 0 bytes in 0 blocks
==2004== Reachable blocks (those to which a pointer was found) are not shown.

Details:

==2004== 7,818 (192 direct, 7,626 indirect) bytes in 1 blocks are definitely lost in loss record 93 of 93
==2004== at 0x4C292C7: operator new(unsigned long) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==2004== by 0x42FFF1: Glacier2::Blobject::Blobject(IceUtil::Handle<Glacier2::Instance> const&, IceInternal::Handle<Ice::Connection> const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&) (in /usr/bin/glacier2router)
==2004== by 0x45DDCD: Glacier2::ServerBlobject::ServerBlobject(IceUtil::Handle<Glacier2::Instance> const&, IceInternal::Handle<Ice::Connection> const&) (in /usr/bin/glacier2router)
==2004== by 0x450C2A: Glacier2::RouterI::RouterI(IceUtil::Handle<Glacier2::Instance> const&, IceInternal::Handle<Ice::Connection> const&, std::string const&, IceInternal::ProxyHandle<IceProxy::Glacier2::Session> const&, Ice::Identity const&, IceUtil::Handle<Glacier2::FilterManager> const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&) (in /usr/bin/glacier2router)
==2004== by 0x468106: Glacier2::CreateSession::sessionCreated(IceInternal::ProxyHandle<IceProxy::Glacier2::Session> const&) (in /usr/bin/glacier2router)
==2004== by 0x4ECF82F: Glacier2::CallbackNC_SessionManager_create<Glacier2::AMI_SessionManager_create>::__completed(IceInternal::Handle<Ice::AsyncResult> const&) const (in /usr/lib64/libGlacier2.so.3.4.2)
==2004== by 0x52CD42A: Ice::AsyncResult::__response() (in /usr/lib64/libIce.so.3.4.2)
==2004== by 0x52CD6ED: IceInternal::OutgoingAsync::__finished(IceInternal::BasicStream&) (in /usr/lib64/libIce.so.3.4.2)
==2004== by 0x5239B55: Ice::ConnectionI::dispatch(IceUtil::Handle<Ice::ConnectionI::StartCallback> const&, std::vector<IceInternal::Handle<IceInternal::OutgoingAsyncMessageCallback>, std::allocator<IceInternal::Handle<IceInternal::OutgoingAsyncMessageCallback> > > const&, unsigned char, int, int, IceInternal::Handle<IceInternal::ServantManager> const&, IceInternal::Handle<Ice::ObjectAdapter> const&, IceInternal::Handle<IceInternal::OutgoingAsync> const&, IceInternal::BasicStream&) (in /usr/lib64/libIce.so.3.4.2)
==2004== by 0x523B1C4: Ice::ConnectionI::message(IceInternal::ThreadPoolCurrent&) (in /usr/lib64/libIce.so.3.4.2)
==2004== by 0x5352178: IceInternal::ThreadPool::run(IceUtil::Handle<IceUtil::Thread> const&) (in /usr/lib64/libIce.so.3.4.2)
==2004== by 0x5352A67: IceInternal::ThreadPool::EventHandlerThread::run() (in /usr/lib64/libIce.so.3.4.2)

(Doing more iteration the number of lost blocks grow up linearly, stopping the client, glacier2router never release any memory.)

Comments

  • mes
    mes California
    Hi,

    Thanks for reporting this, we'll look into it.

    Regards,
    Mark
  • I done some more test and I found that with the previous Ice version (Ice 3.4.1) there are no leaks.
    I guess the problem is related to changes introduced in Glacier2/RequestQueue files
  • mes
    mes California
    You are correct. I've posted a patch that fixes the leak.

    Thanks again,
    Mark