Results 1 to 2 of 2

Thread: About memory leak of Servant Program

  1. #1
    ehero's Avatar
    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.

  2. #2
    bernard's Avatar
    bernard is offline ZeroC Staff
    Name: Bernard Normier
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Palm Beach Gardens, FL
    Posts
    1,294
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. About memory leak in MFC program with Ice2.1.2
    By ehero in forum Help Center
    Replies: 1
    Last Post: 07-14-2005, 01:23 PM
  2. Replies: 3
    Last Post: 04-28-2005, 11:08 AM
  3. Proxy and memory leak
    By fengxb in forum Help Center
    Replies: 2
    Last Post: 11-29-2004, 04:52 PM
  4. maybe memory leak in Linux
    By dragzhb in forum Help Center
    Replies: 6
    Last Post: 10-08-2004, 01:37 AM
  5. With MFC, memory leak?
    By alwayscy1 in forum Help Center
    Replies: 4
    Last Post: 11-05-2003, 08:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •