Hello team,

MongoDB Go bulk write takes up an slice of interfaces which is slice of 
operations.
*https://go.dev/play/p/2vcHx5EFK5x *

While doing so I create a empty slice and add operations to it. When the 
length of slice is > 10K, I do a bulk write to DB.

The problem here is this script eats more memory as it runs, I suspect 
issue is with the slice which gets appended periodically. I try to reset 
the slice but it never gets freed up. Alloc in runtime.MemStats grows to 1 
GB immediately within 1 minute.

Any idea as to who to release the memory of slice every 10k docs ?

The length and cap of slice goes back to zero, but GC does not clean it up. 
Not sure if since its in the for loop the variable is still being 
referenced.

How do solve this problem ?

Regards,

Gowtham

-- 
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/0be9320a-e004-49b0-a88f-79158c1ed0d2n%40googlegroups.com.

Reply via email to