4 ms·
There are some general tricks that are language-agnostic, like allocating a huge "buffer" object when the app starts, the size of which is some significant port
by 013a 6y ago
There are some general tricks that are language-agnostic, like allocating a huge "buffer" object when the app starts, the size of which is some significant portion of the memory you allow the process to use, which always has a reference, then storing references to other objects you need in that big object. In other words, circumvent the garbage collector.
Of course, this has its own issues, but I've seen it done in e.g. Go before. Its likely you'll inevitably end up with leaks, but if your service is fungible and can tolerate restarts, basically what you're doing is moving the "GC Pause" to be a "Container Restart" pause, which may be slower, but would happen less often. Some languages have ways to manually call the GC (Node is not one of them, afaik).
- the8472 6y agoNode allows you to call global.gc() if you enable that functionality with a separate argument. In many cases this is an anti-pattern that would make your application behavior worse rather than better, that's why you have to opt into that.
- eggsnbacon1 6y ago> There are some general tricks that are language-agnostic, like allocating a huge "buffer" object when the app starts I've only seen this done in Go :)
- milesvp 6y agoIt's a fairly common thread in game development circles. Usually game development is one of the few places with big enough constraints that it's worth doing your own memory management in languages that have garbage collectors. Other places it often makes sense to just architect around GC pauses, since you're going to want redundancy and load balancing anyways.