An Intraweb applications requires the same Memory Management as any other Delphi application, there is no Garbage Collection, so you need to make sure there will be no memory leaks when using Objects, DLLs or any other framework that allocates memory inside your application.
As a small guide line you should:
- Make sure you have control of the creation and destruction of your own object instances.
- Try to have a single line of delegation when creating objects. The same object that creates their inner objects instances is responsible for freeing them, so if you create Instances inside the TUserSession DataModule, be sure all of them will be freed before ht TUserDatamodule is destroyed.
- Use Try..Finally blocks in code sections when creating, using and destroying classes that are used only in that section.
- Use Object pooling for boost performance if you want to avoid creating/destroying of objects repeatedly. This generates a certain number of object instances at server startup, each instance will be locked by quest of any Thread/UserSession/Object, and freed when its usage is finished. This allows to have the memory usage more in control.