1

I've developed a Chrome Extension that cycles through approximately 1500-2000 pages to collect information from a website and push it onto my own server. I use a Chrome extension, as given the requirements it's much easier to configure than making and parsing from the server side.

The extension is used only for internal purposes and we trigger this job using the chrome.alarm API to run at 3:00 am every day. This alarm when triggers pops open a new tab and runs through the 1500-2000 pages. The problem is when we check in the morning we see the SNAP dialogue after the extension has cycled through about 1500 pages (approx 3/4). I'm presuming this is due to the memory demand placed on Chrome to maintain such an unusually large history?

My question is, what would be the best way to mitigate this? Presumably killing the tab and reopening (after x number of pages) would work but that would slow down the feed and require quite a bit of code re-factoring. Is there any way you can force Chrome to dump the history and would doing so free memory in the immediate session?

Just to add some context, I am running this on a extra small VM with only 1 GB of memory. I appreciate I could upgrade the VM but that really just defers the problem.

4

1 回答 1

1

如果没有看到您的代码,很难做出可靠的建议,但这里有一些更笼统的东西:

问题很可能是正在收集的信息。它会继续在内存中积累,直到你用完为止。您可以考虑使用 Chrome 的无限存储功能将结果保存到本地存储。在清单文件中:

 "permissions": [
   "unlimitedStorage"
 ],

我可能会做的是在每一页之后保存到本地存储,或者类似的东西,然后重置数组(或者你正在使用的任何东西)。

更新

如果确实是历史问题,您可以考虑即时删除它。此函数将删除特定 URL 的条目:

https://developer.chrome.com/extensions/history.html#method-deleteUrl

于 2013-06-13T00:58:54.420 回答