when is the web module is created / destroyed? lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- egsuh · 2020-05-24 06:58 Hi, I've developed a web-server application using fpweb.  Two webserver applications with the same TFPWebModules, one in CGI and another in FCGI. With CGI model, I have two TFPWebModules (let's say wm1, wm2) and one TDataModule (dm1).  DM1 contains database access and common functions. My question is, I cannot put any of these modules in the "Auto-create forms". They are just in available forms. Well, the web modules (wm1 and wm2) seem to be created automatically because the application works even I did nothing to create them. But where should I create dm1?  Well, I can put it in the OnDataModuleCreate event handler of wm1. For example, Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure Twm1.DataModuleCreate(Sender: TObject);begin   dm1 := Tdm1.Create(nil);   Log('wm1 created')end;  But then,  Twm1.DataModuleDestroy is not called even in the CGI model. So I cannot destroy dm1. If I access web-server again, the dm1 is created again. This is quite big memory loss. When are the web modules are created? And how can I destroy them? ---------------------------------------------------------------------- trev · 2020-05-24 12:55 I'm not familiar with web and data modules, but I have written many CGI programs. As for destroying modules, this should surely happen by default when the CGI program terminates. CGI programs are not persistent. They get loaded by a request to the web server, they run and then they (should) terminate. Perhaps your CGI programs are not terminating for some reason? ---------------------------------------------------------------------- egsuh · 2020-05-25 08:17 QuotePerhaps your CGI programs are not terminating for some reason? That depends on the module kind. If I set it as wkOneShot, it is automatically terminated.  But not if set to wkPooled. In CGI module, this should not make any differnece, but it does. It seems to be a kind of bug (I think this is already reported to bug-tracker).