tlsClient icon indicating copy to clipboard operation
tlsClient copied to clipboard

[BUG] Memory Issue/Ineffective Garbage Collection

Open DemonMartin opened this issue 1 year ago • 3 comments

I'm running into problems with memory leaks and ineffective garbage collection.

Steps to Reproduce

  1. Create an instance of the TlsClient wrapper.
  2. Perform a network request using the instance.
  3. Terminate the worker pool.
  4. Observe the memory not fully freeing up, leading to gradual memory build-up.

The test.js includes parts of the test I tried using Heap Snapshots

Expected Behavior Memory is completely freed up when the worker pool is terminated, preventing any leaks and allowing for long-term stable memory usage.

Actual Behavior Some memory remains allocated after the worker pool is terminated, leading to eventual memory overflow and crashing the application.

I've tried various approaches to identify and fix the underlying cause but haven't had any success so far.

Thanks!

DemonMartin avatar May 11 '24 11:05 DemonMartin

a solution for this will be amazing. cant run many instances because of that.

pepedro12 avatar Jul 11 '24 20:07 pepedro12

has solution was found?

pepedro12 avatar Jul 22 '25 12:07 pepedro12

@pepedro12 Considering I switched to use koffi and a session/module logic, it's slightly better than when I opened this issue. Sadly it's still not optimal. It's very CPU/RAM heavy; That might be caused by Node.js itself.

If you correctly implement it and make Sure to not use too many threads (default value is fine), then it works good.

DemonMartin avatar Jul 22 '25 12:07 DemonMartin