3 ms·
I believe that fragmentation isn't such a problem in Go programs because they make less use of the heap than Java programs. I can't remember where I read this
by nickcw 10y ago
I believe that fragmentation isn't such a problem in Go programs because they make less use of the heap than Java programs. I can't remember where I read this though.
I don't know much about the internals of Java, but I know that Go will stack allocate any kind of object if the compiler can prove it doesn't escape, and that in Go lots of things (not just native types) are passed by value on the stack instead of by reference to a heap value.
- vvanders 10y agoSure, I guess I'm just floored that you'd have a system that doesn't compact and has no manual mechanisms for allocation. I guess it's just a different class of problems that I'm used to dealing with. Fragmentation is something I've seen many times and it usually likes to rear it's head at the worst possible moment.
- krakensden 10y ago> has no manual mechanisms for allocation Golang supports value types for objects, so arrays (or something higher level like sync.Pool) work great for doing arena allocation.
- pcwalton 10y ago> I don't know much about the internals of Java, but I know that Go will stack allocate any kind of object if the compiler can prove it doesn't escape This is also the case in HotSpot.