WApplication destruction
Added by Pat Ivory about 11 years ago
Through experimentation I have noticed a behaviour of the WApplication class.
When the web browser closes the "tab" that is displaying my WApplication, the WApplication's destructor is called, and things are tidied up as I would hope, and expect. When the user closes the browser itself, the destructor of the WApplication is not called, and I would therefore assume that the children on this instance are not being tidied up, and would constitute a pretty severe memory leak?
This behaviour can be seen using the hello example and in browsers; Chrome, Firefox and Internet explorer. I have applied the setCloseMessage, and the close message is being displayed no matter which way the web app is left (tab close, or browser close). So it appears as though the WApplication is aware that it should be closing under both circumstances, yet destruction only occurs for one method.
It's feasible for my WServer instance to poll the WApplication instances to check that they are still alive and operational, but if there is another solution I am open to suggestions?
Thanks,
Patrick
Replies (2)
RE: WApplication destruction - Added by Koen Deforche almost 11 years ago
Hey Patrick,
There is no reliable way to catch the event of the browser closing the tab.
In any case however will the application destructor be called when the session timeouts.
RE: WApplication destruction - Added by Pat Ivory almost 11 years ago
Hey Koen,
Yeah, I came to terms with this :( Thanks for the reply though!
Pat