CDP Forum Forum Index CDP Forum
User/developer forum for CDP - Control Design Platform
by Industrial Control Design AS
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Destructors

 
Post new topic   Reply to topic    CDP Forum Forum Index -> C++ programming
View previous topic :: View next topic  
Author Message
Imbrondir



Joined: 07 Jun 2007
Posts: 44

PostPosted: Fri 7 Nov 12:22:43 2008    Post subject: Destructors Reply with quote

I have put some code in the destructor of a CDPComponent, thinking it will be called on program shutdown. However it doesn't seem to get called. Do destructors only get called on delete's at runtime, or doesn't the OS (well windows) bother to delete a c++ application properly?
Back to top
View user's profile Send private message
Kent



Joined: 12 Sep 2008
Posts: 12

PostPosted: Fri 7 Nov 14:16:43 2008    Post subject: Reply with quote

C++ destructors are only called at run-time, and not by the OS process cleanup, so we can't blame Windows on this one. (The OS process exit cleanup should free up the memory allocated, though.)

Likely this is a bug in CDP if the destructors aren't called. I ran into a similar issue for CDP global component objects recently. The CDPComponent objects have a long life-time in a CDP application, meaning due to potential dangling pointers, they cannot be deallocated until fairly late. This means that even if/when the Component destructors are called, you will not be able to rely on much of CDP to be in an initalized state while in the CDPComponent destructor.

So depending on what you are trying to do, it might make more sense to run this as part of Suspend state transition or in the Destroy virtual method (which should be called regardless of the destructor).

Hope this helps,
_________________
Kent Dahl - Software Developer
Industrial Control Design AS - http://www.icd.no/
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    CDP Forum Forum Index -> C++ programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group