Re: [go-nuts] Deallocate memory consumption of slice.

2024-08-26 Thread Marvin Renich
* robert engels [240826 12:24]: > But why would you want to allocate a new array? This would only be required > if the MongoDB call were async, and the array cannot be reused. > > If you keep allocating new arrays you are putting needless pressure on the GC. > True. But I was going on the ass

Re: [go-nuts] Deallocate memory consumption of slice.

2024-08-26 Thread Gowtham Raj
I had models = []mongo.WriteModel{} before , then tried with models = nil, and models[:0]. All same result. For []mongo.WriteModel{} , I expected that memory gets freed up, but it does not. Everytime the append runs to mongo.WriteModel{} memory consumption increases. My doubt is if the models obje

Re: [go-nuts] Deallocate memory consumption of slice.

2024-08-26 Thread robert engels
But why would you want to allocate a new array? This would only be required if the MongoDB call were async, and the array cannot be reused. If you keep allocating new arrays you are putting needless pressure on the GC. > On Aug 26, 2024, at 11:18 AM, Marvin Renich wrote: > > * Gowtham Raj mail

Re: [go-nuts] Deallocate memory consumption of slice.

2024-08-26 Thread Marvin Renich
* Gowtham Raj [240826 11:31]: > > > I have a sample go snippet which pulls 50k rows from source DB and inserts > into target DB. https://go.dev/play/p/IVANZyVUbkm > > 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.

[go-nuts] Deallocate memory consumption of slice.

2024-08-26 Thread Gowtham Raj
I have a sample go snippet which pulls 50k rows from source DB and inserts into target DB. https://go.dev/play/p/IVANZyVUbkm 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 me