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...@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.
On Aug 26, 2024, at 11:11 AM, Gowtham Raj <rgowt...@gmail.com> wrote:I changed and models[:0] behaves the same. memory keeps on increasing and never gets released to OS.
On Aug 26, 2024, at 11:33 AM, Gowtham Raj <rgowt...@gmail.com> wrote:I do have ordered writes. I dont want to create a array every time. I tried using models[:0] but still memory does not come down.