Possibly the biggest misconception systems programmers have about memory is that heap allocation is inherently slow. It doesn’t have to be more than 6 instructions or so in the fast path! In the JVM and modern JS engines it’s about that speed.
-
-
In many cases where you're trying to avoid heap allocation, it's the variance you're trying to avoid, not the performance per se. Most allocators don't have great worst-case performance
-
Especially when you consider cache. Possibly the biggest inherent benefit of stack vs heap is that stack is more likely to be in cache.
- 1 more reply
New conversation -
-
-
malloc() can be very fast if you don’t care about free() doing anything.
-
It can be very fast if you don’t care about success or correctness

- 11 more replies
New conversation -
-
-
Without a way to compact (and thus change pointers "on the fly") you can't do pointer-bump allocations. In C/C++ pointers are exposed and thus cannot easily be adjusted after a compaction.
-
Compaction in C/C++ is (now) actually possible (and practical!)https://github.com/plasma-umass/Mesh …
- 1 more reply
New conversation -
-
-
It's inherent if you don't want massive over-consumption and lack of globally consistent state, which rather sucks in a language with UB/no memory-safety.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
I'm no expert of allocators, but isn't that speed of allocation is because they use bump allocator and they can do that because they have moving GC? Is bump allocator even possible in naitve code? Never thought about that.
-
Bump allocators are perfectly possible in native code, but you can’t easily reuse the memory once it’s been freed. But if you want all of your memory to go away once a frame is drawn to the screen or once a compiler pass finishes they’re great.
- 2 more replies
New conversation -
-
-
GCs are neat because they can build and dynamically evolved object-and-layout-aware thread local Eden Space allocators. It'd be neat to have something do that sort of automatic memory layout and tuning via e.g. PGO (potentially with some fallback to a global Allocator)
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.