This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
GC not works as expected with crypto module #5949
Comments
That's not unexpected. It's an artifact of how buffers and the garbage collector interact. The V8 GC takes a lazy approach to memory management, it tries to do as little work as possible because garbage collection is expensive. The flip side of that is that buffers - which are essentially tiny JS objects that point to memory outside of the JS heap - tend to live longer and hold on to that external memory longer than is strictly needed. It has been addressed to some extent in master but the basic issue will never go away completely. If that's a problem for you, you'll have to invoke the garbage collector manually from time to time. |
greate |
great! |
great! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Here's a simple program that encrypts 16MB data 100 times:
And we can see the gabage collector not work as expected. RSS went up to 300MB, after the encryption it never went down.
I also found that a simple loop of
crypto.randomBytes(16 * 1024 * 1024)
will lead to the same result.With
--expose-gc
supplied, doinggc()
manually after each iteration, RSS only takes up to 65MB.The text was updated successfully, but these errors were encountered: