Are there problems with techniques two and three? If so, is technique one the only viable way to use WebDialogs or can changes be made to techniques two and/or three so the WebDialog instances are released from memory?
you can add that to your code and see how dialog objects stay in memory.[/quote]
Thank you Christian! I’ve updated the test project with your code to reflect the WebDialog Count.
I haven’t looked at the project, but does the memory get released when the session is destroyed? If so, then the memory leak shouldn’t be (too big of) a problem in most applications.
In addition to the WebPage loading faster, there is no waste of extra memory for each WebDialog unless that WebDialog is used. Unfortunately, my experience is that the memory is never released and actually increases with each additional show of the WebDialog. This is a fugly bug!
Have you found a workaround, other than not using dynamic WebDialogs?
Yes. When the Session is destroyed, so are the WebDialog instances. The WebDialog related memory is released too.
For Web Apps that are run all day long by many employees in a business, this bug can mean a significant increase of memory use on the servers. Falling back to non-dynamic WebDialogs can mean much longer load times for the WebPages. It’s a serious bug.
In the Method that is called when the WebDialog is Dismissed, you’ll find RemoveHandler and Sender (aka WebDialog) = Nil. In the example that uses a WebPage Property to reference the WebDialog, I have tried also setting that WebPage Property equal to Nil. The result is the same. Using a WebPage Property or a Variable to reference an instantiated WebDialog leads to a memory leak because the instance is never destroyed/released.
I created this conversation thinking that I might have missed something or used techniques that were known to be bad. It appears that I’m not the only one thinking that each of these techniques should work. If they should, then the underlying bug needs to be fixed. If they should not work then please document another technique for managing dynamic WebDialogs.
[quote=83375:@Greg O’Lone]Ok. For what it’s worth, the first item:
Control on a WebPage does not impact the Object Count or Memory Used
Does not affect the object count because it’s an implicit instance.[/quote]
Understood. It was used as a baseline to show that there is a means of using WebDialogs without any memory leaks.
That’s good to hear! Being able to use WebDialogs dynamically is important so I hope you find the problem and fix it well ahead of 2014r2.
The “At best” part makes it sound like there is a possibility that a fix won’t make it into 2014r2. The only workaround that I’m aware of is to not use dynamic WebDialogs. If that’s an accurate interpretation and the only options are to live with the memory leak or abandon dynamic WebDialogs, please make this fix a priority for 2014r2!
[quote=83638:@Frederick Roller]I’m happy to hear that I misunderstood you and even happier that you already fixed it.
<https://xojo.com/issue/33313>[/quote]
When the beta process starts, please be sure to test this thoroughly and early.