Archived

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

A unsure question about getting data

Hi;
when I got data from the ICE server all the while and the ICE server did not be started, the memory has leaked.
		public void ProcessStart()
		{
			string [] args= new string [1];
			args[0]="";
			Ice.Communicator o_icecomm=Ice.Util.initialize(ref args);
			testIPrx p1=null;
			string sConnectstr = "172.16.166.166" + "PCManager:default -h " + "172.16.166.166" + " -p " + "10007";

			while(true)
			{
				
				try
				{
					
					Ice.ObjectPrx obj = o_icecomm.stringToProxy(sConnectstr);
					p1= testIPrxHelper.uncheckedCast(obj.ice_twoway().ice_timeout(1000).ice_secure(false));       
					System.Threading.Thread.Sleep(1000);
					//obj.ice_timeout(200);
					p1.GetAgentData();// try to connect	
				}
				catch(Ice.ConnectFailedException)
				{
					System.Threading.Thread.Sleep(1000);
				}
				catch(Ice.TimeoutException)
				{
                    System.Threading.Thread.Sleep(1000);
				}
				finally
				{
					
				}
				System.GC.Collect();
			}
		}

Here,I do't destroy communicator in order that the Ice Server send data to the Ice clinet by callback function. I think I only create one communicator ,the memory should not be increased all the while .So I don't destroy it. That code don't include callback part,that is only my test.

Thanks

Comments

  • Hi,
    I destroy the communicator ,the memory has leaked all the same.
    There is a demo.
  • How do you determine that memory leaks? What tools do you use to measure memory?
  • hi,marc
    I only observe the task manage . So I am unsure .But the memory of process do be increased certainly. That is a windows service process.
    Thanks.
  • The task manager shows how much physical memory the Java Virtual Machine (JVM) uses. This is not a good measure for two reasons:
    • The physical memory heavily depends on the paging strategy of the operating system. See also this thread for more information.
    • The memory consumption of the JVM is not the same as the memory consumption of the Java application running in the JVM. The JVM might decide not to give back memory to the operating system, or it might give it back later. That is, from the size of the JVM you cannot deduce the memory consumption of your Ice application.
    (Whatever has been said above for the JVM is also correct for .NET, in case your example above is C# and not Java.)
  • Hi,marc
    I has read that thread. And I understand you said.But at the beginning of the memory of the process is about 13M , after many hours the memory of the process is about 50 M. The total memory increased a bout 50-13M. I doubt some don't be collect in windows service mode.
    Thanks.
  • Hi, I unpacked your archive, built the service, installed it, and started it. I'm not seeing any increase in memory consumption, whether I run the service with or without a server it can talk to. The memory reported by task manager is stable at 13,572 kB for the service.

    So, I'm afraid that I cannot reproduce this. Do you have any more info for how to provoke the problem?

    Thanks,

    Michi.
  • sorry,michi.
    It is my mistake.
    Thank you .
  • So just that in the future we can give better advice to other users who run into the same problem: What exactly was the mistake?
  • Hi,
    because other handles don't be closed in my process,not in this demo. Sorry.
    Thanks a lot.