GC is triggered *after* allocation than crosses boundary. So your second allocation is actually tries to complete before first allocation freed. And Ubuntu with 4GB memory doesn't allow to allocate 4GB memory cause overcommit is not enabled by default.
Use C/C++, or buy more memory, or change your datastructure from slice to slice of slice and allocate second dimension lazely, or call runtime.GC() explicitely between calls to f() (it will block until GC finishes). -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.