I have a TTMSFNCMap, set at design time to use the msOpenLayers Service, on a modal form. This form is created when required. After its been used, the form is disposed using FreeAnNil.
Every time that the form is created, I see that the TTMSFNCMapsOpenLayers constructor is called twice (from TTMSFNCMapsOpenLayersService.DoCreateMaps). The destructor is, however, not called when freeing the form. It is called repeatedly (twice the number of form openings) when the application is closed.
I have a problem where the destructor inherited sometimes causes an access violation on application closing. This leaves the application active in Task Manager.
I have traced the cause for this to one a particular REST operation, of the many which I call, in a totally separate modal form. Simply assigning the JSONValue property from the TCustomRESTRequest.Response to a local variable (after having opened and closed the map form) will result in the above destructor failing.
The map form and the second form appear to work perfectly when used individually.
I am at a loss as to why this might happen, and may not understand you create/destroy policy correctly. But, it appears to me that objects created when a form is created should be destroyed when it is destroyed, and not persist until application termination.
Any comments/advice would be appreciated as this is a serious problem.