作者etrexetrex (moonet)
看板Flash
标题[问题] 用js移除flash 记忆体没回来
时间Mon Oct 1 15:20:11 2012
=== 目标 ===
移除画面上的 flash 时能够清除 flash 所占用的记忆体
=== 实验 ===
假设操作 HTML 字串等於操作记忆体
新增 Object Tag 增加记忆体使用量
移除 Object Tag 减少记忆体使用量
画面上放两个按钮
addFlash
removeFlash
按一下 addFlash 新增一个 Object Tag
按一下 removeFlash 移除所有 Object Tag
=== 实作 ===
=== HTML的部分 ===
<body>
<a href="#" id="addFlash">add flash</a>
<a href="#" id="removeFlash">remove flash</a>
<div id="flashContainer"></div>
</body>
=== js的部分 ===
$(function(){
$("
#addFlash").click(function(){
var random = 'a' + Math.floor(Math.random() * 1000000000);
$("
#flashContainer").append('<div id="'+ random+ '" />');
swfobject.embedSWF("test.swf", random , "908", "560", "10.0.0");
});
$("
#removeFlash").click(function(){
$("
#flashContainer").html("");
});
});
=== 实验结果 ===
chrome, firefox, safari在按下removeFlash时
系统记忆体使用量在1秒内明显下降,好像没按过addFlsah一样
但是 IE 不意外,在按下removeFlash时
系统记忆体使用量开始缓缓下降,过了一分钟还没降到该降到的位置
不知道 IE 怎麽达到移除 flash 时释放记忆体?
(其实也不能说他没有释放,只是他释放得很慢)
--
blog:
http://etrex.blogspot.com/
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.137.198.18
1F:→ etrexetrex:对了 IE是IE9 10/01 15:42