I've a map which has set of keys and pointing to some structs like this. In here i allocate lot of entries and trying to delete them. But the memory usage is not shrinking.
According to this issue <https://github.com/golang/go/issues/20135> it seems how go behave at this point. In there its suggested to create a new map and move all data there for reduced memory usage. But that seems not a better option as it is an expensive operation against such large map. What is the best way to delete a key from map freeing the memory occupied by the Value(a pointer in this case). type Person struct { Name string } func NewPerson(name string) *Person { return &Person{Name: name} } func main() { m := make(map[int]*Person) for i := 0; i < 1000000000; i++ { m[i] = NewPerson("Person" + strconv.Itoa(i)) } for index := 0; index < 10000; index++ { m[index] = nil delete(m, index) } } -- 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.