Title: How to destroy linked objects? Post by: Dany on August 10, 2018, 12:49:47 PM I have a DataModule that is created on the server using an TRtcLinkedModule component. No automatic object creation is performed on the client. When the client wants to dispose of the (client side) object, i found i can call RtcCLientModule.RemoveManagedObjects; and that will destroy the linked object that this client created. Super!
But i still have a problem when that do not happen for some reason. When i terminate my server application, the DACs finalization section is run before the auto-created server-side objects are destroyed so the DAC do not have the DB dll loaded anymore... Boom! I am trying to find a way to destroy the objects when the server has to be "forcefully" terminated, but to no avail. Can you help? TIA, /Dany Title: Re: How to destroy linked objects? Post by: D.Tkalcec (RTC) on August 10, 2018, 01:04:08 PM What do you mean by "DAC"?
Title: Re: How to destroy linked objects? Post by: Dany on August 10, 2018, 01:06:28 PM DAC = Data Access Components. Sorry.
Title: Re: How to destroy linked objects? Post by: D.Tkalcec (RTC) on August 10, 2018, 01:11:49 PM Where is the TDataModule (containing the TRtcLinkedModule) created on the Server and where is it being destroyed? Making sure that the TDataModule is destroyed (after stopping the Server Listener) before the application starts terminating (and finalization sections start executing) should eliminate the problem.
Title: Re: How to destroy linked objects? Post by: Dany on August 10, 2018, 01:22:10 PM I have registered a constructor (or rather several) in a ServerModule containing a TRtcHttpServer and a TRtcServerModule. The TRtcHttpServer has it's ObjectLinks set to ol_AutoClient. The constructor is executed properly. It constructs another DataModule that contains the TRtcLinkedModule component.
Title: Re: How to destroy linked objects? Post by: Dany on August 10, 2018, 01:30:04 PM What i mean is that since RTC can destroy (and will) these objects when everyting is ok, then if i keep a list of my own and traverse that when stopping to listen i'll free modules that RTC have destroyed already. Should i create an owner that asks my modules to notify it upon destruction? Isn't there a call i can do to get "dangling" objects destroyed?
Title: Re: How to destroy linked objects? Post by: D.Tkalcec (RTC) on August 10, 2018, 01:34:18 PM Automatically created Modules are stored inside Sessions, but Sessions aren't destroyed when the Server is stopped, so these Modules will remain in memory until the "rtcDataSrv" units finalization section completes (where "DoneSessions" is called). But this shouldn't be a problem if a Server has already stopped listening and there are no Clients executing code on the Server. So ... what exactly does go BOOM?
Title: Re: How to destroy linked objects? Post by: Dany on August 10, 2018, 01:46:11 PM After successfully calling ListenStop when i terminate the server application.
Here is the callstack when i terminate the server application: Code: :7441ddc2 KERNELBASE.RaiseException + 0x62 This happen so late that the finalization section of the DACs session unit has been executed. So it's client library has been closed. Maybe i'm doing something wrong with the sessions. I have not added any session-specific code yet, though. Title: Re: How to destroy linked objects? Post by: D.Tkalcec (RTC) on August 10, 2018, 01:55:21 PM Are you calling ListenStop, or ListenStopNow?
Title: Re: How to destroy linked objects? Post by: D.Tkalcec (RTC) on August 10, 2018, 02:00:07 PM If your Database components finalization section is being called before RTC components finalization sections, maybe changing that would fix the problem? You should be able to achieve that by adding your Database components units somewhere at the top of your Projects uses list, most importantly above any RTC units or units using RTC units.
Title: Re: How to destroy linked objects? Post by: Dany on August 10, 2018, 02:06:10 PM Tried both, will change to ListenStopNow and see what happens.
Yes, i was thinking about the order of finalization. I'll try that too, but since the IDE (and even other 3rd party stuff) sometimes changes the uses sections that feels a bit "shaky". I have two thing to try no, i'll keep you posted. Thanks, /D Title: Re: How to destroy linked objects? Post by: Dany on August 10, 2018, 03:15:00 PM I am not an expert on units and linking, but after sorting all the uses clauses i put the DAC's unit containing the finalization section firs in the projects dpr-file. This is fine because i can comment and maintain this in a reliable fashion.
Thank you again! /D |