-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add clear-cache option #215
Conversation
This is unexpected, and I don't understand what you mean by
|
It means that this:
removes nothing from the heap. It just allocates more and more memory until the VM memory is full. Libs like decache (see above) try to solve this issue. As we restart our dev-server after every code change anyway, we don't need this behaviour. That's why I introduced this flag. |
NodeJS has a gc.. what do you mean?
Does it really though? You can have a look at what decache does: I'm not sure how it differs from what we're doing. |
I just noticed that the code above leads to memory leaks. I have no details how node handles the require cache internally. But GC'ing required modules is probably a dangerous thing. I would not expect this to work. I remember that I've tested decache when i found the issue and it was working better, but I don't know if it really cleans the cache fully or if the memory leak is just smaller... |
What part? This might be useful |
again, this part
|
This is spinning in circles. Could you provide a reproducible example? |
You can find more details here: nodejs/node#14569 this is a tiny example: file
file
and then run |
Thanks !! |
I've tried your new decache version, but sadly it does not really improve the situation. If i comment out the newly introduced line: |
Hi @ashiina, I'm closing this PR because I've created my own lib to run lambda functions locally. It uses forks / child processes to avoid the memory leaks and problems discussed in this PR. It lacks probably some features lambdaLocal has, but it works very well for us. Since we don't need to clean the require cache and re-requiring the lambda handler for each request, it also runs like 10 times faster. |
Hi,
the strategy of deleting the lambda function from the require cache leads to huge memory leaks in our case, as
delete
seems only to remove the cache key, but not the cached object. I guess you could also use something like decache to cleanly remove the lambda function from cache, but I didn't want to introduce a new dependency to your project. Instead I've added an option to skip the deletion of the cache key, as our dev-server restarts after every code change anyway.