我正在监控我的互联网连接。当没有可用的服务时,我从我的URLMonitor获得一个事件。我正在侦听此事件并调用一个打开SkinnablePopUpContainer的函数。它是一个非常简单的组件,我没有附加到它的侦听器,它只在函数内部定义。当用户单击SkinnablePopUpContainer中的按钮时,我关闭组件并尝试使用我所知道的所有可能方式将其销毁。当我从Flash Builder检查Profiler工具时,SkinnablePopUpContainer仍在那里。如何销毁此组件以释放它正在使用的内存。
这是监听器功能:
protected function onNoServiceAvailable(e:*):void
{
var noserviceWindow:NoInternetError = new NoInternetError();
noserviceWindow.open(this,false);
noserviceWindow.x= 0;
noserviceWindow.y= 0;
noserviceWindow.width = SharedObject.getLocal('localObj').data.appMeasures.appWidth;
noserviceWindow.height = SharedObject.getLocal('localObj').data.appMeasures.appHeight+200;
}
这是我的SkinnablePopUpContainer
<?xml version="1.0" encoding="utf-8"?>
<s:SkinnablePopUpContainer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:nxTextInput="nx.components.extended.nxTextInput.*"
xmlns:nxButton="nx.components.extended.nxButton.*"
backgroundAlpha="0.4"
horizontalCenter="0" verticalCenter="0" width="100%" height="100%">
<fx:Script>
<![CDATA[
protected function loginButton_clickHandler(event:Event):void
{
loginButton.removeEventListener(MouseEvent.CLICK,loginButton_clickHandler);
this.close();
var ob = this;
ob = null;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Panel title="Fehler"
horizontalCenter="0" verticalCenter="0" color="white">
<s:VGroup horizontalAlign="center" verticalAlign="middle" gap="20"
height="100%" width="100%">
<s:BitmapImage source="@Embed('assets/nxInspect/mobile/assetsCI/redAssets/alert_80x80.png')" id="iconBitmpapDownOnline" verticalCenter="0" />
<s:Label id="serviceFailure" text="Keine internetverbindung." width="90%" styleName="interactable" textAlign="center" color="white"/>
<nxButton:NxButton id="loginButton" label="OK" width="100%" height="100" click="loginButton_clickHandler(event)" styleName="alert"/>
</s:VGroup>
</s:Panel>
答案 0 :(得分:1)
首先,行var ob = this;只是为“this”创建一个引用变量。将此变量设置为null不会使其自行删除。它只会重新引用你刚刚创建的变量为null,所以这两行是没用的。
因为你已经在函数onNoServiceAvailable的范围内包含你的局部变量noserviceWindow,所以当没有更多的引用时,它应该被自动标记为垃圾收集。如果你的探查器正在识别它的存在,那么你的代码中可能会有另一个引用它。