<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>FoxLing - 前端开发 &#187; air</title>
	<atom:link href="http://foxling.org/tag/air/feed/" rel="self" type="application/rss+xml" />
	<link>http://foxling.org</link>
	<description>不积跬步 无以至千里</description>
	<lastBuildDate>Sat, 19 Nov 2011 16:29:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Flex 中可能导致内存泄露的地方</title>
		<link>http://foxling.org/as-flex-air/flex-memory-leak/</link>
		<comments>http://foxling.org/as-flex-air/flex-memory-leak/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 17:49:11 +0000</pubDate>
		<dc:creator>FoxLing</dc:creator>
				<category><![CDATA[AS/Flex/AIR]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Memory Leak]]></category>
		<category><![CDATA[内存泄露]]></category>

		<guid isPermaLink="false">http://foxling.cn/?p=392</guid>
		<description><![CDATA[收集了不少的会导致内存泄露的情况： 事件监听： 对父级对象加了监听函数，会造成内存泄露，例： override protected function mouseDownHandler(…):void { systemManager.addEventListener(“mouseUp”, mouseUpHandler); ...... } 解决： 在销毁对象的时候，remove掉这些监听，虽然弱引用也可以避免这些问题，但自己掌控感觉更好。 但以下几种情况不会造成内存泄露： 弱引用：someObject.addEventListener(MouseClick.CLICK, handlerFunction, false, 0, true); 对自己的引用：this.addEventListener(MouseClick.CLICK, handlerFunction); 子对象的引用： private var childObject:UIComponent = new UIComponent; addChild(childObject); childObject.addEventListener(MouseEvent.CLICK, clickHandler); 总之&#8230;有addEventListener，就removeEventListener一下吧，要为自己做的事负责~哈哈 清除引用 remove掉子对象后并不会删除该对象，他还保留在内存中，应该将引用设置为null removeChildren(obj); obj = null; 静态成员 Class （或MXML）中有： public static var _eventService : MyService=new MyService(); 解决：在dispose时，需要设置： _eventService =null; module (未解决) moduleLoader [...]]]></description>
			<content:encoded><![CDATA[<p>收集了不少的会导致内存泄露的情况：</p>
<h3>事件监听：</h3>
<p>对父级对象加了监听函数，会造成内存泄露，例：</p>
<pre>
override protected function mouseDownHandler(…):void {
systemManager.addEventListener(“mouseUp”, mouseUpHandler);
......
}
</pre>
<p>解决：<br />
在销毁对象的时候，remove掉这些监听，虽然弱引用也可以避免这些问题，但自己掌控感觉更好。</p>
<p>但以下几种情况不会造成内存泄露：</p>
<ul>
<li>弱引用：<code>someObject.addEventListener(MouseClick.CLICK, handlerFunction, false, 0, true);</code></li>
<li>对自己的引用：<code>this.addEventListener(MouseClick.CLICK, handlerFunction);</code></li>
<li>子对象的引用：
<pre>
private var childObject:UIComponent = new UIComponent;
addChild(childObject);
childObject.addEventListener(MouseEvent.CLICK, clickHandler);
</pre>
</li>
</ul>
<p>总之&#8230;有addEventListener，就removeEventListener一下吧，要为自己做的事负责~哈哈</p>
<h3>清除引用</h3>
<p>remove掉子对象后并不会删除该对象，他还保留在内存中，应该将引用设置为null</p>
<pre>
removeChildren(obj);
obj = null;
</pre>
<p><span id="more-392"></span></p>
<h3>静态成员</h3>
<p>Class （或MXML）中有：</p>
<pre>public static var _eventService : MyService=new MyService();</pre>
<p>解决：在dispose时，需要设置：</p>
<pre>_eventService =null;</pre>
<h3>module (未解决)</h3>
<p>moduleLoader unloadModule后<br />
ModuleInfo 并不会被GC.<br />
<a href="http://www.nutrixinteractive.com/blog/?p=132">Garbage Collection in a MultiCore Modular Pipes Application</a><br />
这篇文章介绍了一种GC策略，感觉对于ModuleInfo 的GC无效。<br />
(未尝试、未遇到)</p>
<h3>CSS样式</h3>
<p>module 中如果使用了shell的CSS定义或是&lt;mx:Style&gt; 这样的定义，那么这个module将不能GC.<br />
弹出的窗口应该是同样的结果.<br />
解决方法，使用动态CSS文件<br />
module init中</p>
<pre>StyleManager.loadStyleDeclarations("css/myStyle.swf");</pre>
<p>module dispose中</p>
<pre>StyleManager.unloadStyleDeclarations("css/myStyle.swf");</pre>
<h3>TextInput/Textarea(未解决)</h3>
<p>如果module中有window使用了TextInput/Textarea控件，不点击没有问题，只要点上去，那么很遗憾了，module和所在窗体将不能被GC.<br />
这个BUG非常严重，目前还没有解决方法。<br />
<a href="http://bugs.adobe.com/jira/browse/SDK-14781">memory leak when using TextInput and TextArea when click the keyboard</a> 这里面附加的解决方法无效。<br />
通过profiler分析，应该和Focusmanager有关，只有一点击就不会释放。</p>
<h3>CursorManager.setCursor</h3>
<p>使用了</p>
<pre>cursorID = CursorManager.setCursor(iconClosed);</pre>
<p>dispose时要</p>
<pre>CursorManager.removeCursor(cursorID); </pre>
<h3>Bitmap</h3>
<p>如果使用Bitmap，结束时需要调用其dispose方法，否则内存消耗巨大。<br />
另外，BitmapData是可以共享使用的，多个Bitmap可以使用同一BitmapData，节省不少内存。</p>
<pre>
var bmp:Bitmap  =new Bitmap();

........

if (bmp.bitmapData!=null) {
    bmp.bitmapData.dispose();
}
</pre>
<h3>Image</h3>
<p>包含了Image对象时，在removeChildren时会造成不能释放（测试多次，结果不一，建议还是做如下处理）。<br />
解决：</p>
<pre>
img.source = null;
this.removeChild(img);
img = null;
</pre>
<h3>Loader、SWFLoader、声音、视频、Effect等&#8230;</h3>
<ul>
<li>如果是加载SWF文件，先停止播放。</li>
<li>停止声音的播放</li>
<li>停止正在播放的影片剪辑(Movieclip)</li>
<li>关闭任何连接的网络对象，例如Loader正在加载，要先close。</li>
<li>取消对摄像头或者麦克风的引用</li>
<li>取消事件监听器</li>
<li>停止任何正在运行的定时器，clearInterval()</li>
<li>停止任何Timer对象，timer.stop()</li>
<li>停止正在播放的效果(Effect)</li>
</ul>
<h3>其他</h3>
<p>binding也疑似有memory leak 问题。</p>
<p>引用以及内存泄露相关博文和资料：<br />
<a href="http://blogs.adobe.com/aharui/2007/03/garbage_collection_and_memory.html">http://blogs.adobe.com/aharui/2007/03/garbage_collection_and_memory.html</a><br />
<a href="http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/">http://www.craftymind.com/2008/04/09/kick-starting-the-garbage-collector-in-actionscript-3-with-air/</a><br />
<a href="http://www.cnblogs.com/janyou/archive/2008/11/25/1340753.html">http://www.cnblogs.com/janyou/archive/2008/11/25/1340753.html</a><br />
<a href="http://www.dreamingwell.com/articles/archives/2008/05/understanding_m.php">http://www.dreamingwell.com/articles/archives/2008/05/understanding_m.php</a></p>
<p>总结：由于之前Flash一直是在网页上使用，一般网页都是看完就关掉的，估计Adobe在内存回收这块也没有下太大的功夫，现在AIR的出现使得内存管理也相当重要了，并且，AIR本身对内存的消耗就相当大，一个没有任何内容的初始创建的AIR程序，就得占掉10-20M+的内存&#8230;AIR还需改善.</p>
]]></content:encoded>
			<wfw:commentRss>http://foxling.org/as-flex-air/flex-memory-leak/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>魔嘀新版本(更新1.1版本)</title>
		<link>http://foxling.org/as-flex-air/modi-new/</link>
		<comments>http://foxling.org/as-flex-air/modi-new/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 05:03:26 +0000</pubDate>
		<dc:creator>FoxLing</dc:creator>
				<category><![CDATA[AS/Flex/AIR]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[Air应用]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[魔嘀]]></category>

		<guid isPermaLink="false">http://foxling.cn/?p=354</guid>
		<description><![CDATA[经过一段时间的辛苦奋战，魔嘀终于发布1.0了，所有的代码全部重写，增加了一些常用的功能，并请@ZK设计了全新的UI，现在的魔嘀帅多了。 魔嘀下载页面：http://app.foxling.cn/modi/ 但现在还有许多细节都需要优化，时间有限，只能一步一步地更新了~ 如果发现了什么BUG，或有什么好的建议，在这里留言吧，不一定一一回复，但我都会整理记录起来的，并且在后面的版本里陆续实现，欢迎在嘀咕网跟随我，一起交流。 AIR应用的通病，内存消耗较大，所以，建议平时不用时最小化吧，最小化后内存占用会比较少，8M-12M左右，我也在不断地优化代码，寻找BUG，使魔嘀的内存占用量能维持在一个比较稳定的水平。 版本更新 1.0 (2009-04-10)]]></description>
			<content:encoded><![CDATA[<p><a href="http://app.foxling.cn/modi/"><img src="http://foxling.cn/wp-content/uploads/2009/04/modilogo.png" alt="魔嘀Logo" title="魔嘀Logo" width="316" height="128" class="alignright size-full wp-image-355" /></a><br />
经过一段时间的辛苦奋战，魔嘀终于发布1.0了，所有的代码全部重写，增加了一些常用的功能，并请<a href="http://digu.com/tuotuo1020" target="_blank">@ZK</a>设计了全新的UI，现在的魔嘀帅多了。<br />
魔嘀下载页面：<a href="http://app.foxling.cn/modi/" target="_blank">http://app.foxling.cn/modi/</a><br />
但现在还有许多细节都需要优化，时间有限，只能一步一步地更新了~<br />
如果发现了什么BUG，或有什么好的建议，在这里留言吧，不一定一一回复，但我都会整理记录起来的，并且在后面的版本里陆续实现，欢迎在嘀咕网<a href="http://digu.com/foxling" target="_blank">跟随我</a>，一起交流。<br />
AIR应用的通病，内存消耗较大，所以，建议平时不用时最小化吧，最小化后内存占用会比较少，8M-12M左右，我也在不断地优化代码，寻找BUG，使魔嘀的内存占用量能维持在一个比较稳定的水平。</p>
<p><img src="http://foxling.cn/wp-content/uploads/2009/04/modi.png" alt="魔嘀新界面" title="魔嘀新界面" width="429" height="473" class="aligncenter size-full wp-image-357" /></p>
<h3>版本更新</h3>
<ul>
<li>1.0 (2009-04-10)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://foxling.org/as-flex-air/modi-new/feed/</wfw:commentRss>
		<slash:comments>97</slash:comments>
		</item>
		<item>
		<title>Air学习笔记，窗体常用操作</title>
		<link>http://foxling.org/as-flex-air/air-nativewindow-method/</link>
		<comments>http://foxling.org/as-flex-air/air-nativewindow-method/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 15:10:00 +0000</pubDate>
		<dc:creator>FoxLing</dc:creator>
				<category><![CDATA[AS/Flex/AIR]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[窗体操作]]></category>

		<guid isPermaLink="false">http://wp.foxling.cn/as-flex-air/air-nativewindow-method/</guid>
		<description><![CDATA[HTML窗体对象：window.nativeWindow .visible [true&#124;false] 隐藏/显示窗体，隐藏一个窗体将取消窗体的显示以及相关的任何栏图标 .maximize() 最大化窗体 .minimize() 最小化窗体 .close() 关闭窗体 .restore 还原窗体 .startResize() 改变窗体大小，当该方法在mouseDown 事件里调用时，大小改变是由鼠标确定的，当系统接收到mouseUp事件则停止大小调整。 .startMove() 移动窗体]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.foxling.cn/attachments/month_0901/y200911323129.png" alt="" style="float: right;" />HTML窗体对象：window.nativeWindow</p>
<p>.visible [true|false]<br />
隐藏/显示窗体，隐藏一个窗体将取消窗体的显示以及相关的任何栏图标</p>
<p>.maximize()<br />
最大化窗体</p>
<p>.minimize()<br />
最小化窗体</p>
<p>.close()<br />
关闭窗体</p>
<p>.restore<br />
还原窗体</p>
<p>.startResize()<br />
改变窗体大小，当该方法在mouseDown 事件里调用时，大小改变是由鼠标确定的，当系统接收到mouseUp事件则停止大小调整。</p>
<p>.startMove()<br />
移动窗体</p>
]]></content:encoded>
			<wfw:commentRss>http://foxling.org/as-flex-air/air-nativewindow-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dreamweaver CS4 AIR开发环境</title>
		<link>http://foxling.org/as-flex-air/dreamweaver-cs4-air/</link>
		<comments>http://foxling.org/as-flex-air/dreamweaver-cs4-air/#comments</comments>
		<pubDate>Sun, 11 Jan 2009 13:55:25 +0000</pubDate>
		<dc:creator>FoxLing</dc:creator>
				<category><![CDATA[AS/Flex/AIR]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[JS]]></category>

		<guid isPermaLink="false">http://wp.foxling.cn/as-flex-air/dreamweaver-cs4-air/</guid>
		<description><![CDATA[AIR可以使用 HTML, CSS 和 JavaScript进行开发，赶紧学习学习~ 下载Adobe AIR 扩展 for Dreamweaver 这个插件生成的时候，需要JRE支持~在这里下载安装 事实上，写一个AIR应用相当简单，你只要写HTML+CSS+JS，然后通过这个DW的扩展Cr&#101;ate AIR File，就搞定了~~ 如果CSS加载不成功~~这是AIR的BUG，打开注册表，找到：HKEY_CLASSES_ROOT / .css 找到Content Type的值，修改为：text/css]]></description>
			<content:encoded><![CDATA[<p><img style="float: right; margin-left: 10px;" src="/attachments/month_0901/92009111212437.jpg" alt="" /> AIR可以使用 HTML, CSS 和 JavaScript进行开发，赶紧学习学习~</p>
<p>下载<a href="http://www.adobe.com/products/air/tools/ajax/#section-2" target="_blank">Adobe AIR 扩展 for Dreamweaver</a></p>
<p>这个插件生成的时候，需要JRE支持~<a target="_blank" href="http://www.java.com/zh_CN/download/windows_ie.jsp?locale=zh_CN&amp;host=www.java.com&amp;bhcp=1">在这里下载安装</a></p>
<p>事实上，写一个AIR应用相当简单，你只要写HTML+CSS+JS，然后通过这个DW的扩展Cr&#101;ate AIR File，就搞定了~~</p>
<p>如果CSS加载不成功~~这是AIR的BUG，打开注册表，找到：HKEY_CLASSES_ROOT / .css</p>
<p>找到Content Type的值，修改为：text/css</p>
]]></content:encoded>
			<wfw:commentRss>http://foxling.org/as-flex-air/dreamweaver-cs4-air/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

