Based on what you describe and without the code to know what you're doing, it's a bit difficult to help you. But come on.
One approach would be to put the basics of the basics in these DMs. That is, only the DataSets you will actually use. Whatever is accessory you can create at runtime. In this case, the inheritance might help a lot, leaving the repeating part of the code in DMpai.
Another thing that can help is to use create a connection singleton or even create a pool. Depending on the bank you are using, it may be that many transactions / connections are holding too much resource without releasing. With the singleton / connection pool, you can lessen this possibility of error.
Another question is: Arrange the house before exiting DM
. Close DataSet's
, terminate the active transactions, close the connections (or return them to the pool). Another detail is that if you are using TFDQuery
, and creating it at runtime, ensure that it will destroy it ( Try... finally
) using Release instead of Free
direct. The Release
method makes memory releases that .Free
does not. Do not ask me why the two are public because I do not know.
Finally, if your project allows you to work with the same instance of DataModule
, you only need to build a factory and a singleton class to give you back the DMs you need.