Archived
This forum has been archived. Please start a new discussion on GitHub.
Memory leak when I dynamicly call a proxy function!
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 don't understand what you mean with "dynamic" in the 2nd example. All I can see is that you destroy and create a communicator for every call. This is of course very inefficient, but there should be no memory leak. How do you know that there is a memory leak, i.e., what tools do you use to detect the leak, and what is leaking exactly?0
-
I run in win32
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.0 -
The memory is indeed increasing a little bit when a communicator is destroyed and a new one is created. We will investigate this.
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.0