我在Flash Builder 4.5上构建了一个基于Flex视图状态的简单视频应用程序。有4个州。每当我从State1-> State2-> State3或State1-> State2-> State4时,Internet Explorer中的内存会增加,但不会被释放。我什么不解除分配?
我是否必须为每个状态手动释放每个元素及其事件侦听器?
我安装了Flash Player 10,2,153,1。
如果您要构建应用并运行,则源代码下载为here。
这是核心代码:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width.State1="1024" height.State1="768"
width.State2="1024" height.State2="768"
width.State3="1024" height.State3="768"
width.State4="1024" height.State4="768">
<fx:Script>
<![CDATA[
protected function button1_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
currentState='State2';
}
protected function button2_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
currentState='State3';
}
protected function button3_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
currentState='State1';
}
protected function button4_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
currentState='State2';
}
protected function button5_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
currentState='State4';
}
]]>
</fx:Script>
<s:states>
<s:State name="State1" />
<s:State name="State2"/>
<s:State name="State3"/>
<s:State name="State4"/>
</s:states>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Button includeIn="State1" x="405" y="175" width="227" height="73" label="Music List"
click="button1_clickHandler(event)" fontSize="30" itemDestructionPolicy="auto" />
<s:Label includeIn="State1" x="440" y="61" fontSize="30" text="Main State" itemDestructionPolicy="auto"/>
<s:Label includeIn="State2" x="409" y="34" fontSize="30" text="Classical Video" itemDestructionPolicy="auto"/>
<s:Button includeIn="State2" x="328" y="151" width="369" height="91"
label="Beethoven - "Für Elise"" click="button2_clickHandler(event)"
fontSize="30"
itemDestructionPolicy="auto"
/>
<s:VideoPlayer includeIn="State3,State4" x="0" y="67" width="1024" height="530" autoPlay="false"
loop="true" scaleMode="stretch" source="assets/Beethoven__Für_Elise.mp4"
source.State4="assets/FOUR_SEASONS_VIVALDI_LANDSCAPES_AND_MUSIC.mp4"
itemDestructionPolicy="auto"
/>
<s:Button includeIn="State3,State4" x="2" y="14" width="240" height="45" label="Return to Main"
click="button3_clickHandler(event)" fontSize="30"
itemDestructionPolicy="auto"
/>
<s:Button includeIn="State3,State4" x="338" y="629" width="348" height="63" label="Return to classical"
click="button4_clickHandler(event)" fontSize="30"
itemDestructionPolicy="auto"
/>
<s:Button includeIn="State2" x="326" y="287" width="371" height="81"
label="Vivaldi – “Four Seasons”" click="button5_clickHandler(event)" fontSize="30"
itemDestructionPolicy="auto"
/>
</s:Application>
来自“游荡对象视图”中最顶层对象的对象引用(http://help.adobe.com/en_US/flashbuilder/using/WSe4e4b720da9dedb5510654d812e4d126514-8000.html#WS6f97d7caa66ef6eb1e63e3d11b6c4d0d21-7eef)的视图在这里
我查看了文档“Controlling caching of objects created in a view state”并设置了itemDestructionPolicy =“auto”。它仍在缓存对象,并且没有释放内存,如任务管理器中所示。