3 ms·
Just an additional note (though I’m coming from the Java side of things), in some managed languages the difference between the stack and the heap is also not as
by kaba0 3y ago
Just an additional note (though I’m coming from the Java side of things), in some managed languages the difference between the stack and the heap is also not as significant as they are in a malloced, manual language. E.g. in case of Java, there is a specific region called the thread-local allocation buffer. This is a region where most objects get allocated to, then the ones that are still alive are moved to an older generation, while the rest is cleared (and used as basically an arena allocator). This is only owned by a single thread, no locks, regularly in cache, there is no real difference to “the stack” from a hardware perspective, like nothing is fundamentally different about the stack.