Archived
This forum has been archived. Please start a new discussion on GitHub.
About memory leak of Servant Program
in Help Center
I implement the servant of interface A with AImp.
But I want to call the local AImp and remote AImp with APrx.
When I use AImp class directly,
such as A* a = new AImp();
Because interface A has no virtual destroy function, memory leak happens.
What's more, when I use AImpPtr, memory leak happens too.
Why?
But I want to call the local AImp and remote AImp with APrx.
When I use AImp class directly,
such as A* a = new AImp();
Because interface A has no virtual destroy function, memory leak happens.
What's more, when I use AImpPtr, memory leak happens too.
Why?
0
Comments
-
A small code sample would be useful to find this leak!
How did you find out that you have memory leak? Just a cerr in AImp's destructor?
With reference counted objects such as the generated C++ class for the Slice A interface/class, I recommend you always use Ptr and never plain pointers, e.g.:
APtr a = new AImp();
Also, if you add this servant to your adapter's servant map, the servant map will keep a reference-count until you remove this servant from the map, or you deactivate the adapter (this happens automatically when you shutdown or destroy the communicator). So don't forget to shutdown/destroy your communicator.
I hope this will put you on the right track!
Bernard0