Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

内存无法释放 #23

Closed
anota opened this issue May 14, 2014 · 3 comments
Closed

内存无法释放 #23

anota opened this issue May 14, 2014 · 3 comments

Comments

@anota
Copy link

anota commented May 14, 2014

我使用这个模块,把我的图片都加上尺寸,发现跑了2000多张图片的时候内存暴涨,而且save之后也没发释放。请问有什么办法?

var im = images(path);
var fr = fs.readFileSync(path);
var picSize = im.size().width + "*" + im.size().height;
var fileSize = fr.length;
im = null;
fr = null;
@zhangyuanwei
Copy link
Owner

@anota github里面的最新修改增加了内存回收机制,可以试试:
images.setGCThreshold(1024*1024); //设置内存回收阈值为1Mb
这样在每次新增内存达到1M时,自动执行V8的内存回收。

@anota
Copy link
Author

anota commented May 15, 2014

好的 辛苦了

@anota anota closed this as completed May 15, 2014
@zhangyuanwei
Copy link
Owner

另外,虽然实现了,但是不建议使用,因为垃圾回收的操作很慢,而V8会在内存确实不够的时候调用垃圾回收。如果有1G内存,程序只用了1023M,那就有1M是浪费了^_^。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants