--
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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Your program completes without any trouble on my machine, but do note if we enter the following in an emacs scratch buffer and hit C-j to use it as a glorified calculator:(/ (* 3e8 8) (* 1024 1024 1024))2.2351741790771484If each element in your array takes up 8 bytes, which is the case for a 64bit integer, then you need at least 2.2 gigabytes of memory to allocate the array.
Looking at your output, it is clear your operating system is not allowing you to malloc some contiguous piece of space for this.
There are a couple of possible things to look out for:* 32bit systems can often allocate a constrained amount of memory in one go.* You may be limited articifically by the operating system, either through cgroups or the 'ulimit' facility, though the latter has a rather peculiar way of working on linux.* You may not have enough memory in your system.In practice, a garbage collector will usually seek to allocate more space than what is needed. If we run your program with
[jlouis@lady-of-pain z]$ GODEBUG=gctrace=1 ./zgc 1 @0.000s 16%: 0.003+0+0.34 ms clock, 0.014+0/0/0+1.3 ms cpu, 0->0->0 MB, 0 MB goal, 8 P (forced)gc 2 @0.020s 0%: 0.066+256+0.048 ms clock, 0.26+0/0.038/0.097+0.19 ms cpu, 2288->2288->2288 MB, 2289 MB goal, 8 P89we can see the garbage collector collects twice. The first one is probably forced by the SetGCPercentage call. The second because of the rather large allocation that is happening. And the amount of needed memory more or less coincides with the 3e8 * 8 calculation above.
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).
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 a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/HrZpsyfb3i0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts+unsubscribe@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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...@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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...@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.