Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 07-12-2005
ehero's Avatar
ehero ehero is offline
Registered User
 
 
Join Date: Mar 2005
Location: Beijing, China
Posts: 9
About memory leak of Servant Program

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?
__________________
I'm ehero.
I love database and middleware.
Reply With Quote
  #2 (permalink)  
Old 07-13-2005
bernard's Avatar
bernard bernard is offline
ZeroC Staff
 
Name: Bernard Normier
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Palm Beach Gardens, FL
Posts: 816
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!

Bernard
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
About memory leak in MFC program with Ice2.1.2 ehero Help Center 1 07-14-2005 02:23 PM
Does it mean that there are memory leak problems in my program? yrh79 Help Center 3 04-28-2005 12:08 PM
Proxy and memory leak fengxb Help Center 2 11-29-2004 05:52 PM
Memory leak when using ice with MFC? _orchid_ Help Center 9 12-01-2003 07:02 PM
With MFC, memory leak? alwayscy1 Help Center 4 11-05-2003 09:48 PM


All times are GMT -4. The time now is 09:49 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.