Home Help Center

How to release object.

laoteelaotee Member ✭✭
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

  • michimichi Member Michi HenningOrganization: Triodia TechnologiesProject: I have a passing interest in Ice :-) ✭✭✭
    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.
  • laoteelaotee Member ✭✭
    Thanks ,but I want to release that objects by myself. May I do it?
  • laoteelaotee Member ✭✭
    Another,Will the communications Handle be create when I execute that code ? How do I close the Handles
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    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"?
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    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?
  • laoteelaotee Member ✭✭
    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 .
  • michimichi Member Michi HenningOrganization: Triodia TechnologiesProject: I have a passing interest in Ice :-) ✭✭✭
    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.
  • laoteelaotee Member ✭✭
    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 .
  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    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.
  • laoteelaotee Member ✭✭
    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.
  • michimichi Member Michi HenningOrganization: Triodia TechnologiesProject: I have a passing interest in Ice :-) ✭✭✭
    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.
  • laoteelaotee Member ✭✭
    Thank you.
    I am reading it now.
Sign In or Register to comment.