A "memory leak" used to mean memory that had been manually allocated and was no longer reachable. Then folks using GC languages redefined it to mean any memory that was hanging around that you didn't need any more.
"Memory unsafety" means it is possible to misinterpret what a set of bits in memory represent. For example, in C you can cast an integer to a pointer and then try to dereference the result, potentially segfaulting the application.
Now this article is trying to redefine "memory unsafe" to mean, what exactly? That you can allocate lots of memory? Then by that token arrays in JS are not "memory safe":
$ node
> var a = [];
undefined
> for (var i = 0; i < 100000000; i++) a = [a];
<--- Last few GCs --->
16440 ms: Mark-sweep 1373.8 (1403.0) -> 1373.8 (1404.0) MB, 685.4 / 0.0 ms [allocation failure] [GC in old space requested].
17196 ms: Mark-sweep 1373.8 (1404.0) -> 1373.8 (1404.0) MB, 674.5 / 0.0 ms [allocation failure] [GC in old space requested].
17945 ms: Mark-sweep 1373.8 (1404.0) -> 1373.8 (1403.0) MB, 667.3 / 0.0 ms [last resort gc].
18710 ms: Mark-sweep 1373.8 (1403.0) -> 1373.8 (1403.0) MB, 764.7 / 0.0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0xc1e0c2cfb51 <JS Object>
1: /* anonymous */ [repl:~1] [pc=0x14e5000b32af] (this=0xc1e0c2e6ec1 <JS Global Object>)
5: /* anonymous */(aka /* anonymous */) [vm.js:22] [pc=0x14e50009fd28] (this=0xc1e0c204381 <undefined>)
6: sigintHandlersWrap(aka sigintHandlersWrap) [vm.js:96] [pc=0x14e50009ee68] (this=0xc1e0c204381 <undefined>,fn=0x2fb44a970289 <JS Function sigintHandlersWrap (SharedFunctionInfo 0x3acca3663cd1...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [/usr/local/bin/node]
2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/node]
3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
4: v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/usr/local/bin/node]
5: v8::internal::Runtime_AllocateInTargetSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
6: 0x14e4fff079a7
Abort trap: 6
That definition doesn't make sense. Promises are memory safe (and do not leak memory either). But you can use them to build a linked list of arbitrary length.
78
u/munificent Oct 11 '17
A "memory leak" used to mean memory that had been manually allocated and was no longer reachable. Then folks using GC languages redefined it to mean any memory that was hanging around that you didn't need any more.
"Memory unsafety" means it is possible to misinterpret what a set of bits in memory represent. For example, in C you can cast an integer to a pointer and then try to dereference the result, potentially segfaulting the application.
Now this article is trying to redefine "memory unsafe" to mean, what exactly? That you can allocate lots of memory? Then by that token arrays in JS are not "memory safe":
That definition doesn't make sense. Promises are memory safe (and do not leak memory either). But you can use them to build a linked list of arbitrary length.