Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Interesting, and I think that is not specific to Go, other mark-and-sweep GCs (Java, C#) should behave the same.

Which means that creating short lived objects (like iterators for loops, or some wrappers) is ok.



Not entirely. Go still doesn't have a generational collector so high allocation rates cause more GC's that must examine long-lived objects.

As such, short-lived objects have little impact in Java (thank god for that!). They will have second order effects in Go.


It should be noted that in C#, at least, the standard pattern is to use value types for enumerators, precisely so as to avoid heap allocations. This is the case for all (non-obsolete) collections in the .NET stdlib - e.g. List<T>.Enumerator is a struct.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: