I imagine it must make a bigger difference in languages where allocations are more costly too. E.g. in Go sorting to count uniques is most certainly much faster than using a map + it saves memory too
This doesnt concerns in-language allocations at all. There is only one large allocation for both, done up-front. The slowdowm has to do with cashe misses and cpu cashe capacity, which is optimisations the cpu does when executing. Granted, a language like go may have more of the cpu cashe used up by different runtime checks. Basically, i think this analysis largely language agnostic.
For example, if you were to benchmark this in Java, the HashMap class allocates (twice!) on every insertion. Allocations are a bit cheaper with the GC than they would be via malloc/friends, but still we'd expect to see significant allocator and hence GC overhead in this benchmark