Memory leak when I dynamicly call a proxy function!

in Help Center
When I call a proxy staticly,there is no memory leak,
But when I dynamicly call a proxy,memory leak happens
demo:
1) No memory leak
Ice::CommunicatorPtr communicator;
communicator = Ice::initializeWithProperties(argc, argv, properties);
...init proxy...
while(true)
{
...
call proxy;
...
}
if(communicator)
{
try
{
communicator->destroy();
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
//status = EXIT_FAILURE;
}
}
2)Has memory leak
while(true)
{
Ice::CommunicatorPtr communicator;
communicator = Ice::initializeWithProperties(argc, argv, properties);
...init proxy...
...
call proxy;
...
if(communicator)
{
try
{
communicator->destroy();
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
//status = EXIT_FAILURE;
}
}
}
But when I dynamicly call a proxy,memory leak happens
demo:
1) No memory leak
Ice::CommunicatorPtr communicator;
communicator = Ice::initializeWithProperties(argc, argv, properties);
...init proxy...
while(true)
{
...
call proxy;
...
}
if(communicator)
{
try
{
communicator->destroy();
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
//status = EXIT_FAILURE;
}
}
2)Has memory leak
while(true)
{
Ice::CommunicatorPtr communicator;
communicator = Ice::initializeWithProperties(argc, argv, properties);
...init proxy...
...
call proxy;
...
if(communicator)
{
try
{
communicator->destroy();
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
//status = EXIT_FAILURE;
}
}
}
0
Comments
I run my exe in win2000,I use taskmgr to detect the exe memory increase
quickly!
"dynamic" means I call proxy once a time,when proxy call finished,I must
reget proxy from communication.
However, why do you create and destroy communicators for every call? Even if the small memory leak is fixed, this is highly inefficient. You can update your proxy without recreating the communicator.