GitSquared / node-geolite2-redist

Redistribution of MaxMind GeoLite2 GeoIP databases as an npm library
https://gitsquared.github.io/node-geolite2-redist/
Other
72 stars 15 forks source link

Fix OOM due to update avalanches #7

Closed RealDolos closed 4 years ago

RealDolos commented 4 years ago

Problem

Result

Process went up to consume 20GB of physical memory, swapping out most the physical memory of most other processes and eventually getting OOM killed by the kernel. Oops.

Fix

Remove the lastUpdateCheck/checkUpdates() calls from the proxy object completely. The UpdateSubscriber will perform these anyway already. No need to have this triggered on property access, kinda redundant.

Also, move out the proxyObject.subscriber setup from the proxy get into the main wrapReader body. No need to permanently check the creation when it's created exactly once anyway.

Also, triggerUpdate() is useless; stubbed.

GitSquared commented 4 years ago

Thanks for the PR. Will release 1.0.7 in a few minutes. :+1:

RealDolos commented 4 years ago

Update tests

I knew I wanted to do something more before submitting the PR o_O

GitSquared commented 4 years ago

No problem, tests are a pain in the *** to update, I don't blame you :smile: