Hi,
I have a memory leak problem with a widget I have constructed, and after pulling it apart bit by bit I found out what is causing the leak, but am stuck as how to solve it (beside not using a widget and putting the functionality back into the window).
Basically I have a created a Facebook widget that lets me POST to a Facebook time line (with a image), controller code below.
The widget is on a Modal Window that pops up when a user selects a button.
var facebook = Alloy.Globals.Facebook; facebook.appid='xxxxxxxxxxxxxxxxx'; $.fbButton.style = facebook.BUTTON_STYLE_WIDE; $.facebookButton.enabled = facebook.loggedIn; facebook.addEventListener('login', function(e) { $.facebookButton.enabled = true; }); facebook.addEventListener('logout', function(e) { $.facebookButton.enabled = false; });The 2 offending articles are the event listeners which I use to enable and disable the 'Post to Facebook' button.
Remove them and the closing parent modal window behaves and gets garbage collected, leave them in and I build up TiUIWindowProxy objects.
So if I need to remove the event Listeners (not sure why this should be required), how would I let the widget know that the container window is closing and so it should do a 'destruct/destroy'?
As an aside I defined my Facebook app id in the tiapp.xml
<property name="ti.facebook.appid">xxxxxxxxxxxx</property>And that all works fine in emulator when testing, but do an ADHoc build and the code errors with no facebook appid defined, hence I added it to the widget controller code as well, is this right or should it work defined in the tiapp.xml.