3 ms·
C# does... you can stackalloc. I don't see the incompatibility -stack isn't managed by the GC, so the stack isn't affected by the GC's operations, doesn't need
by Pannoniae 3y ago
C# does... you can stackalloc.
I don't see the incompatibility -stack isn't managed by the GC, so the stack isn't affected by the GC's operations, doesn't need to be pinned or anything
Why can't GC'd languages provide access to the stack?
- jppittma 3y agoIf you care so deeply about memory access that you want control over stack allocation, you probably care enough that you don't want a GC. What's your use case where the GC doesn't murder you, but you care about better cache locality?
- adgjlsfhk1 3y agoObjects on the stack don't participate in the GC (technically they're GC roots). Half of the reason you want to be able to put variables on the stack is because the stack variables are managed by lifetime and therefore the GC doesn't have to collect them.
- thfuran 3y agoIsn't more explicit control of memory allocation useful precisely in the places where the default behavior would murder you? I don't see the incompatibility. Many python and java programs have portions that are native code for performance reasons (though that's not necessarily just about GC). What's relatively rare is a program where the whole thing is absolutely performance critical rather than just some parts.