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

Memory leak #23

Open
hlherrera opened this issue Sep 5, 2019 · 1 comment
Open

Memory leak #23

hlherrera opened this issue Sep 5, 2019 · 1 comment

Comments

@hlherrera
Copy link

if I have an express controller:

Controller.js

`model: string //path

postMethod(text) {
const textClassifier = new Fasttext(model); // here memory leak!
return textClassifier.predict(text);
}
`
Memory grows without limit on every request.
Screen Shot 2019-09-05 at 12 14 03 PM

@vunb
Copy link
Owner

vunb commented Sep 6, 2019

Hi, you should try to declare textClassifier as a reference variable at top level of controller. Don't create new in every requests.

Example:

Controller.js

model: string //path
textClassifier = new Fasttext(model);

postMethod(text) {
  return textClassifier.predict(text);
}

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