node-fasttext icon indicating copy to clipboard operation
node-fasttext copied to clipboard

Memory leak

Open hlherrera opened this issue 6 years ago • 2 comments

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

hlherrera avatar Sep 05 '19 16:09 hlherrera

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

vunb avatar Sep 06 '19 02:09 vunb