On Sat, Mar 13, 2021 at 5:52 PM Kevin Chadwick <m8il1i...@gmail.com> wrote:

> Very little resources, unless the map is actually used and not for long. If 
> you really need to control gos memory use, you need to preallocate arrays in 
> a long standing manner anyway, not for maps though, as you can't delete 
> without realloc.

How did you figure out "very little resources"?

What if there's a hot loop called a billion times doing something and
returning a non zero map in the very last call? We're then talking
about probably measurable slowdowns and gigabytes of garbage the
collector has to deal with. Allocating "preemptively" might be
sometimes a good idea, but that's a decision better left to humans as
the compiler usually does not have enough info to make that decision
right.

Ignoring for now other techniques that might get the cost of this
down. They exist.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAA40n-UVHC7BtSJQoq%3DLZ-h4%3D97f7nMnTw0TWT%3DH8ceT85dGkw%40mail.gmail.com.

Reply via email to