ZeroC

Archived

This forum has been archived. Please start a new discussion on GitHub.

How to release object.

o_icecomm = Ice.Util.initialize(ref arg);
Ice.ObjectPrx obj = o_icecomm.stringToProxy(sConnectstr);
PCManagerPrx PCmanager= PCManagerPrxHelper.checkedCast(obj);
Ice.ObjectAdapter  adapter = o_icecomm.createObjectAdapterWithEndpoints("PCManagerAdapter","tcp:udp");
adapter.add(new ServerCallBackI(PCmanager),Ice.Util.stringToIdentity("servercallback"));
adapter.activate();
how to release the objects: obj ,PCmanager,adapter.

Comments

  • michi
    michi
    You don't need to release objects explicitly with Ice. You can simply let the references go out of scope, and Ice will clean up for you. The only explicit cleanup action that is required on your part is that you must destroy the communicator before exiting. Please check out the documentation for more details.

    Cheers,

    Michi.
  • laotee
    laotee
    Thanks ,but I want to release that objects by myself. May I do it?
  • laotee
    laotee
    Another,Will the communications Handle be create when I execute that code ? How do I close the Handles
  • marc
    marc Florida
    You seem to be working with Java, so I don't understand the question. Java has automatic garbage collection. What exactly do you mean with "release"?
  • marc
    marc Florida
    laotee wrote:
    Another,Will the communications Handle be create when I execute that code ?

    Sorry, but I don't understand this question either. What is a communications handle?
  • laotee
    laotee
    marc wrote:
    You seem to be working with Java, so I don't understand the question. Java has automatic garbage collection. What exactly do you mean with "release"?
    I am working with C#.My program is a Windows Service .When I start my program with Windows Service Mode,GC don't collect.But when I start my program with Console Mode,GC can collect .
  • michi
    michi
    Sorry, I'm confused. Whether you run an Ice program as a stand-alone program or as a Windows service makes no difference. The C# garbage collector runs regardless. What makes you think that you need to release anything?

    Cheers,

    Michi.
  • laotee
    laotee
    marc wrote:
    Sorry, but I don't understand this question either. What is a communications handle?
    The Handle what I said be like Socket Handle. Certainly, I don't know the handle exist in ICE or not .
  • marc
    marc Florida
    laotee wrote:
    The Handle what I said be like Socket Handle. Certainly, I don't know the handle exist in ICE or not .

    You don't have to care about connections, Ice does all of this automatically. Please see the Ice manual, Chapter 33 ("Connection Management") for details.
  • laotee
    laotee
    michi wrote:
    Sorry, I'm confused. Whether you run an Ice program as a stand-alone program or as a Windows service makes no difference. The C# garbage collector runs regardless. What makes you think that you need to release anything?

    Cheers,

    Michi.

    I'm confused too.
    when I run my program as a Windows service ,I observe Handle Count in Task Manager. The handle count is increased at all times.But I run an Ice program as a stand-alone program ,the Handle count is increased or decreased. so I want to Know the handle exist in ICE or not.
  • michi
    michi
    It is impossible to leak memory (or any other resources) with Ice for C#. I suspect that the problem may be elsewhere in your server. Or are you leaking servants? In that case, I suggest you read Connections #3, which discusses how to get rid of servants that are no longer needed by clients.

    Cheers,

    Michi.
  • laotee
    laotee
    Thank you.
    I am reading it now.