buffer.clear() method to explicitely free memory #2995
Comments
Curious: What problem would this solve? When does the freeing when the garbage collector is run not work out? |
Having manual memory management along with an automatic (GC) is a waste of resources and will lead to incorrect application design. Additionally, there're no real benefits of that, as it was pointed by @TooTallNate |
We're not going to do that. Buffers have been designed around the fact that they're immutable in size. Changing that will introduce all kinds of obscure bugs in both Node and third-party code for little to no benefit. |
Thanks @trevnorris for the incoming buffer.dispose() ! |
@lfortin no promises that it'll be implemented in core. If not then I'll find a way to make this work in a module. |
404 on the trevnorris/node@36b13c7 |
@ivanseidel Here's the module: https://www.npmjs.org/package/buffer-dispose |
Thanks @trevnorris ! |
What could be very nice:
1- provide a method to explicitly clear a buffer immediately, and all the memory it takes:
2- Make sure that memory is immediately freed when a buffer variable goes out of scope.
Example:
The text was updated successfully, but these errors were encountered: