-
Notifications
You must be signed in to change notification settings - Fork 0
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
使用 mc.get 的时候出现 heap out of memory 错误 #10
Comments
具体的使用代码是怎样的? |
你截图明显是内存爆了。 |
extend context mcCache(key, handle, time = 5 * 60000) {
if (typeof key !== 'string') {
throw new Error('key must be string');
}
key = key.replace(/\s/g, '_'); // 替换非法字符
return co(this.mc.get(key)).then(res => {
if (res) {
this.app.logger.debug(`${key} has cache: ${res}`);
return Promise.resolve(res);
} else {
return Promise.reject();
}
}).catch(() => {
return co.apply(this, [handle]).then(res => {
if (res && (!res.error || !_.isError(res.error))) {
try {
const resString = (typeof res === 'object') ? JSON.stringify(res) : res;
this.mcSet(key, resString + '', time);
} catch (e) {
this.app.logger.error(e);
}
}
return Promise.resolve(res);
});
});
}, router const result = yield this.mcCache(
`pinyin_${pinyin}`,
function* test() {
const result = yield this.proxy.xxx.getXXX({
args: pinyin,
});
return result;
}
); 返回的数据量大小就是一个接口响应的 json 数据,数据量为 5KB。 |
把coredump文件发给我 帮你分析下吧。这样看代码 不行的。 |
经测试内容在3K以上都会出现这个问题 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
如图:
缓存的数据是一大段 json 字符串,大小为 5KB ,使用了 yield mc.get 就会抛出以上错误,如果不使用 yield 就不会抛出异常,能正常取到数据。
The text was updated successfully, but these errors were encountered: