Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 09-25-2008
soff.dong soff.dong is offline
Registered User
 
Name: qiao dong
Organization: accurad
Project: v6's net project
 
Join Date: Jun 2008
Location: china xian
Posts: 12
Send a message via MSN to soff.dong
-->
Smile About garbage collector

I need to use the data which i get from ICE,but i want Keep it until i finish the job,but garbage collector will delete it when the flow finish.
Or maybe ican shut garbage collector down.
can you help me? TKS.
Reply With Quote
  #2 (permalink)  
Old 09-25-2008
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,088
If you hold a reference the GC will not trash the data. If this is not occurring then there is some problem... If you think you've found a bug the simplest method is to send us a self-contained, compilable example based on the latest version of Ice which demonstrates the problem.
Reply With Quote
  #3 (permalink)  
Old 09-26-2008
soff.dong soff.dong is offline
Registered User
 
Name: qiao dong
Organization: accurad
Project: v6's net project
 
Join Date: Jun 2008
Location: china xian
Posts: 12
Send a message via MSN to soff.dong
-->
Cool sorry about my describe.

No,It's not bug.
for example:
client use callback send msg to server and receive some info in class CallbackReceiverI : public CallbackReceiver{}, when CallbackReceiverI finsih, the data will be delete by ICE,i guess it's garbage collector ,but i don't want put my deal fuction in the class CallbackReceiverI : public CallbackReceiver{}, i want to keep them in memery until i delete it.

of course, i can copy it in class CallbackReceiverI : public CallbackReceiver{}, but it's too slow,so i want keep the primary data as well.

TKS.
__________________
Reply With Quote
  #4 (permalink)  
Old 09-26-2008
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,088
Sorry, its still not clear what you are doing. Could you give a concrete example?
Reply With Quote
  #5 (permalink)  
Old 09-26-2008
michi's Avatar
michi michi is offline
ZeroC Staff
 
Name: Michi Henning
Organization: ZeroC
Project: Ice
 
Join Date: Feb 2003
Location: Brisbane, Australia
Posts: 931
Quote:
Originally Posted by soff.dong View Post
No,It's not bug.
for example:
client use callback send msg to server and receive some info in class CallbackReceiverI : public CallbackReceiver{}, when CallbackReceiverI finsih, the data will be delete by ICE,i guess it's garbage collector ,but i don't want put my deal fuction in the class CallbackReceiverI : public CallbackReceiver{}, i want to keep them in memery until i delete it.
The GC is disabled by default. So, unless you've turned it on explicitly, by setting Ice.GC.Interval or by explicitly calling Ice::collectGarbage, there will be no garbage collection. The one exception to this rule is that, when you destroy a communicator, the Ice run time makes a collection pass to reclaim the memory for any abandoned class cycles.

Also, the only class instances that the collector deals with are those that are part of a cycle. Any class instance that is not part of a cycle is reclaimed when its reference count drops to zero, that is, when the last smart pointer to the instance goes out of scope.

The garbage collector guarantees that it will collect only instances that are no longer reachable by any smart pointer in your program. If you have an instance you would like to hang onto, the reason almost certainly is that you are not keeping a smart pointer for the instance in scope that would keep it's reference count non-zero. This has nothing to do with the collector--it is simply a matter of how you use smart pointers.

Do not keep C++ pointers or references to a class instance in your program. If you do, they will point into outer space once the last smart pointer to the instance goes out of scope.

Quote:
of course, i can copy it in class CallbackReceiverI : public CallbackReceiver{}, but it's too slow,so i want keep the primary data as well.
There is usually no need to copy the class instance if you want to keep it around. Instead, you can keep a smart pointer to the instance. Assignment of the smart pointer has essentially zero cost and is much cheaper than instantiating and copying the instance itself.

I suggest that you have a look at the "Smart Pointers for Classes" section in the Chapter 6 of the Ice Manual.

If the issue you are seeing is indeed caused by the garbage collector, we'll need a code example that demonstrates the problem.

Cheers,

Michi.
Reply With Quote
  #6 (permalink)  
Old 09-26-2008
soff.dong soff.dong is offline
Registered User
 
Name: qiao dong
Organization: accurad
Project: v6's net project
 
Join Date: Jun 2008
Location: china xian
Posts: 12
Send a message via MSN to soff.dong
-->
I Get It ! Thank You , Both Of You!!
__________________
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
Garbage Collection Troubles Nis Baggesen Help Center 8 02-15-2006 11:46 AM
Incorrect note about C++ garbage collector in documentation ? chaukmean Bug Reports 1 11-28-2003 04:11 PM


All times are GMT -4. The time now is 05:28 PM.


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