Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 06-21-2005
laotee laotee is offline
Registered User
 
 
Join Date: Jun 2005
Posts: 41
a question about memory

for(int i=0;i<100;i++)
{
try
{
o_icecomm = Ice.Util.initialize(ref arg);

Ice.ObjectPrx obj = o_icecomm.stringToProxy("PCManager:default -h 172.16.166.6 -p 10000");
PCManagerPrx PCmanager= PCManagerPrxHelper.checkedCast(obj);
..........
}
catch
{

}
}

when the program is executed, throw exceptions.because I did not start service of ICE. I find that memoy of thread grow fastly.why?

thank you.
Reply With Quote
  #2 (permalink)  
Old 06-21-2005
matthew's Avatar
matthew matthew is offline
ZeroC Staff
 
Name: Matthew Newhook
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Feb 2003
Location: NL, Canada
Posts: 1,052
Are you destroying the communicator? If not, you should. its not clear why you'd want to create a communicator over & over again. What do you hope to achieve by doing this?

Regards, Matthew
Reply With Quote
  #3 (permalink)  
Old 06-21-2005
laotee laotee is offline
Registered User
 
 
Join Date: Jun 2005
Posts: 41
for example: I Input a IP of server,but if the server is not open ,connection will not be created. PCManager will be created
continuously ,but the creation is not successful every time , memory group continuously.my purpose is to connect the server realtime.
Reply With Quote
  #4 (permalink)  
Old 06-21-2005
matthew's Avatar
matthew matthew is offline
ZeroC Staff
 
Name: Matthew Newhook
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Feb 2003
Location: NL, Canada
Posts: 1,052
You only need to create the communicator once, not over & over again. The problem in your application most likely is that you do not call destroy() on the communicator, so the resources are never released.

Matthew
Reply With Quote
  #5 (permalink)  
Old 06-21-2005
laotee laotee is offline
Registered User
 
 
Join Date: Jun 2005
Posts: 41
I call destroy() ;

for(int i=0;i<100;i++)
{
try
{
o_icecomm = Ice.Util.initialize(ref arg);

Ice.ObjectPrx obj = o_icecomm.stringToProxy("PCManager:default -h 172.16.166.6 -p 10000");
PCManagerPrx PCmanager= PCManagerPrxHelper.checkedCast(obj);
..........
}
catch
{
o_icecomm = Ice.Util.initialize(ref arg);/////////////////////////////////
Ice.ObjectPrx obj = o_icecomm.stringToProxy("PCManager:default -h 172.16.166.6 -p 10000");

PCManagerPrx PCmanager= PCManagerPrxHelper.uncheckedCast(obj);
o_icecomm.destroy();

}
}


but,the resources are not released.
Reply With Quote
  #6 (permalink)  
Old 06-21-2005
marc's Avatar
marc marc is online now
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,781
I don't see destroy being called for the communicator in the try-block. You apparently create a new communicator in the catch-block (why?), which then gets destroyed, but only if the catch-block itself doesn't raise an exception.

Please have a look at one of the Ice demos and the Ice manual for more information on how to properly initialize and shut down communicators.
Reply With Quote
  #7 (permalink)  
Old 06-21-2005
laotee laotee is offline
Registered User
 
 
Join Date: Jun 2005
Posts: 41
Because I only destroy the communicator that was not connect.

If it throws exception in "PCManagerPrx PCmanager= PCManagerPrxHelper.checkedCast(obj);" . I only want to destroy the communicator in "Ice.ObjectPrx obj = o_icecomm.stringToProxy("PCManager:default -h 172.16.166.6 -p 10000");". If it does'n throws exception,I shall create communicator and connect. So I destroy communicator in Catch-block.
Reply With Quote
  #8 (permalink)  
Old 06-21-2005
matthew's Avatar
matthew matthew is offline
ZeroC Staff
 
Name: Matthew Newhook
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Feb 2003
Location: NL, Canada
Posts: 1,052
I don't understand what you are trying to say. But the sample code you pasted is not correct. It should read something like:

o_icecomm = Ice.Util.initialize(ref arg);

for(int i=0;i<100;i++)
{
try
{
Ice.ObjectPrx obj = o_icecomm.stringToProxy("PCManager:default -h 172.16.166.6 -p 10000");
PCManagerPrx PCmanager= PCManagerPrxHelper.checkedCast(obj);
..........
}
catch
{
Ice.ObjectPrx obj = o_icecomm.stringToProxy("PCManager:default -h 172.16.166.6 -p 10000");

PCManagerPrx PCmanager= PCManagerPrxHelper.uncheckedCast(obj);

}
}

o_icecomm.destroy();

You should not create the communicator over and over again.

Matthew
Reply With Quote
  #9 (permalink)  
Old 06-22-2005
laotee laotee is offline
Registered User
 
 
Join Date: Jun 2005
Posts: 41
Thank for you help.I know. 谢谢.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
A question about memory limit in Ice. ehero Help Center 3 06-28-2005 11:35 AM
A question about decrease memory laotee Help Center 5 06-27-2005 06:25 AM
Mismatched memory question stephan Help Center 6 03-28-2005 09:14 PM
question about memory mgmt Baloo Help Center 2 10-01-2004 07:02 PM
In-memory IceStorm vukicevic Patches 2 01-20-2004 08:56 PM


All times are GMT -4. The time now is 09:08 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.