trevnorris / buffer-dispose Goto Github PK
View Code? Open in Web Editor NEWIncredibly unsafe way to free a Buffer
License: MIT License
Incredibly unsafe way to free a Buffer
License: MIT License
Hi Trevor,
I found this project while researching gc issues in our current project that uses lot's of buffer objects. At some point, all the garbage collections we see using --trace_gc
are full mark&sweeps due to reaching v8's "external memory allocation limit".
The buffer-dispose you have here seems like a viable solution. Though I wonder whether v0.10 is affected by this just as much as v0.11?
Personally, I would vouch for something like this to make it into node core at some point. Any GC system has to make a tradeof at some point between consistency and performance. In this case, calling free on a buffer remains entirely optional and an optimization.
e.g. .NET gives you the IDisposable pattern to early-release native resources that would else require expensive finalization during garbage collection. This is a similar scenario. Nothing bad happens if you don't free a buffer but if you want more performance you can dispose it. In any case, a disposed buffer should throw exceptions anytime it's beeing accessed (in .NET disposed objects throw ObjectDisposedException
), and you need to be careful about disposing elements at the right time (e.g. when working with async callbacks like in node). With a node.js buffer, the native resource is the external memory held.
So, from my point of view, this is nothing out of the ordinary and "dangerous" stuff, it's one of the core things a GC'd platform needs to provide to its developers to allow writing performant code. At it's current state, the buffer handling and gc characteristics make node.js unusable for us (long gc pauses, soft realtime requirements, loads of buffer handling and weak/embedded hardware)
Regards,
Johannes
This library is outdated (and seems abandoned by the owner?)
npm WARN package.json [email protected] No repository field.
npm http GET https://registry.npmjs.org/buffer-dispose
npm http 200 https://registry.npmjs.org/buffer-dispose
npm ERR! notarget No compatible version found: buffer-dispose@'*'
npm ERR! notarget No valid targets found.
npm ERR! notarget Perhaps not compatible with your version of node?
npm ERR! notarget This is most likely not a problem with npm itself.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! System Windows_NT 6.2.9200
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.