3 ms·
If you use a pool, you can explicitly return memory to it without going through the GC. This causes mark/sweep cycles to occur less often. In a non-generationa
by stcredzero 13y ago
If you use a pool, you can explicitly return memory to it without going through the GC. This causes mark/sweep cycles to occur less often.
In a non-generational collector, why less often? Is it that the GC "sees" less garbage, and this figures into the frequency of mark/sweep cycles?
EDIT: Okay, I just got it. If you assume it's a bump allocator, it's easiest to picture. So Go does have another big advantage with regards to reducing GC pressure, in that one can stack allocate structs and arrays. (One would be passing slices on those arrays most often, and stack allocated would be slightly less flexible, of course.)
- pcwalton 13y agoRight. See the documentation here [1]. Typically GCs run on allocation when they see a high ratio of the live set from the previous run to total memory in use. [1]: http://golang.org/pkg/runtime/debug/#SetGCPercent http://golang.org/pkg/runtime/debug/#SetGCPercent