我有一个非常复杂的扩展名,但我会简化问题,可以轻松地复制。铬扩展内存猪基本功能
manifest.json的:
{
"name": "script",
"version": "1.0",
"description": "script",
"browser_action": {
"default_icon": "icon.jpg"
},
"permissions": [
"tabs",
"http://www.google.com/"
],
"background_page" : "background.html",
"content_scripts":[
{
"matches":["http://www.google.com/"],
"js":["/jquery.js","/script.js"]
}
] }
的script.js:
var item = null;
restart();
function restart() {
item = null;
item = new Object();
item.Go = Go;
item.Go();
}
function Go() {
setTimeout(function() { restart(); }, 5);
}
background.html:什么也不做,现在
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="http://code.jquery.com/jquery-1.4.2.min.js" language="javascript" type="text/javascript"></script>
</head>
<body>
</body>
</html>
现在,当我的项目应该做的非常简单...刷新页面,抓取数据,将结果发布到本地jsonp Web服务,重复。我遇到了chrome选项卡和扩展程序内存问题,可以通过在chrome中按SHIFT + ESC来查看扩展程序。运行上述Chrome扩展,您可以慢慢看到页面大小不断增加。通过上面的示例,您可以看到该选项卡增加,但扩展内存使用量不会增加,直到事情变得更加困难。
为什么内存使用量会不断增加,唯一发生的事情是正在创建的项目,然后一次又一次地失效?不应该从内存中清除对象吗?
我想你可能已经简化了太多。刮取的数据发生了什么? – mraaroncruz 2010-08-11 01:58:41