Archived

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

A question about decrease memory

My program includes many ICE client.
I find when I execute this code to create ICE client:

o_icecomm = Ice.Util.initialize(ref arg);
Ice.ObjectPrx obj = o_icecomm.stringToProxy(sConnectstr);
PCManagerPrx PCmanager= PCManagerPrxHelper.checkedCast(obj);//end

,The memoy increase. As the Clients of ICE increase ,the memory of the program increase. I think if I create 200 clients of ICE in the program ,the memory is about 400M. So .my computer is very "slow"! In the case, how can I decrease the memory?

thanks!

Comments

  • benoit
    benoit Rennes, France
    It looks like your code creates many communicators. A communicator is not a light weight object: you should share a single communicator object instead of creating 200 of them. Or is there any specific reasons for creating so many communicator objects?

    To release the memory allocated by a communicator object, you need to destroy the communicator:
      o_icecomm.destroy();
    

    Hope this helps.

    Benoit.
  • I don't understand how do I share a single communicator object instead of creating 200 of them. I need many conncetors when my parogram has been executed,not one connector. So my communicators will be destroy only that the program is closed.or the server program is closed.
  • benoit
    benoit Rennes, France
    Perhaps I misunderstood your original post but I was under the impression that you were creating 200 communicators within the same process, in which case you could simply use a single shared communicator instead (even if you're connecting to multiple servers...).

    Is your application actually creating 200 processes, each process being an Ice client connecting an Ice server? I'm not sure what is your concern with respect to memory in this case... Can you detail a little more your application so that we can better help you?

    Benoit.
  • public  void createICEagent()
    {
    string ConnectIP=string.empty;
      IList lstIp=new ArrayList();
      Ice.Communicator o_icecomm = null;
      o_icecomm = Ice.Util.initialize(ref arg);
      lstIp.Add("172.16.16.16");
      lstIp.Add("172.16.16.12");
      lstIp.Add("172.16.16.13");
      lstIp.Add("172.16.16.15");
    for(int i=0;i<lstIp.Count;i++)
    { 
       try
       {
         ConnectIP=lstIp[i];
         Ice.ObjectPrx obj = o_icecomm.stringToProxy(ConnectIP);
          PCManagerPrx PCmanager= PCManagerPrxHelper.checkedCast(obj);
       }
      catch
      {
    
      }
    
    }
    

    when I executed this code ,the memory increase 4 times.because I create 4 clients.
  • benoit
    benoit Rennes, France
    I suppose that by Ice "client" you actually mean Ice "proxy". I don't see why creating a proxy and doing a checkedCast on this proxy would consume a lot of memory -- it shouldn't.

    The best way to investigate this problem would be to send us a small self-compilable example demonstrating it, please also specify which OS and Ice version you are using.

    Btw, I'm not sure if is intended or not, but "172.16.16.15" is a stringified proxy representing an indirect proxy containing only the object identity "172.16.16.15" (it's not interpreted as an IP address!). If your goal is to invoke on an object which is hosted by the host with the "172.16.16.15" IP address, the proxy should be something like: "myobject:tcp -h 172.16.16.15 -p 12345" where "myobject" if the identity of the object.

    Benoit.