Memory overflow because of dynamic import?

35 Views Asked by At

I am trying to find the reason why in my node API memory accumulates and ultimately at some point crashes my node app because it has no memory anymore.

The only thing I can think of is that this might be a problem:

I have a long running function which I access via tinypool, so that it does not block everything else. TinyPool is imported using dynamicImport.

export const importDynamic = new Function(
  "modulePath",
  "return import(modulePath)"
);

export const longRunningFunction = async (
  
) => {
  const { Tinypool } = await importDynamic("tinypool");

  const worker = new Tinypool({
    filename: new URL(
      "./worker.js",
      url.pathToFileURL(__filename).toString()
    ).href,
  });

  // ......
};

the long running function gets accessed very often. Can this import be the problem why my memory overflows at some point?

Cheers and thanks!

0

There are 0 best solutions below