vunb / node-fasttext

Nodejs binding for fasttext representation and classification.
MIT License
43 stars 14 forks source link

Memory leak #23

Open hlherrera opened 5 years ago

hlherrera commented 5 years ago

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 commented 5 years ago

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);
}