Jump to content

Creating and Destroying DataModules


Recommended Posts

Hi there!


I am not sure if I am doing right with datamodules.


I am following the demos and implemented the folloging in my code:


function DMMainG: TDMMainG;
  Result := TDMMainG(UniMainModule.GetModuleInstance(TDMMainG));

So, I add my unit with the datamodule and then i use the above function to get the valid instance of the it.


However I am lost, WHAT IS THE REASON of doing this way?


On the destructor of my Form I am not not doing FREE on the datamodule. Because if I do so, the next time it is instantiated it do not works correctly: I use DBISAM and the Database and Session components does not get created and the datamodule fails.


Then I am writing the application always never doing FREE on the datamodule, and always calling that GetModuleInstace. 


I would like to know what is this way, is that is correct, because I am getting some instabilities on the application and I am not sure if this is the reason.


Thank you !!!





Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...