Perhaps a small program that reproduces the issue would help. 

I wrote a quick one: https://play.golang.org/p/hbnuZsEqUKV . However, after 
an hour of running I see no "leak". I am on "go1.14 windows/amd64". After  
6,000,000 iterations and 4 TB total allocated The memory stats (HeapInuse 
and HeapAlloc) are still dancing around the same values they had at the 
start. And Windows still reports the same 11.9-12.1 MB of memory used that 
it did at the start.


On Monday, April 27, 2020 at 12:58:54 AM UTC-4, Naveen Kak wrote:
>
> I have my system up and running for let's say 10 hours or so where these 
> operations on map ( continuous add/delete) keep happening. Memory keeps 
> growing and goes very high. 
> Eventually at end of test we clear all map entries, memory is reclaimed 
> and is good. 
> It's basically kind of load test. 
> Appreciate your engagement. 
>
> On Mon, 27 Apr, 2020, 3:41 AM Ian Lance Taylor, <ia...@golang.org 
> <javascript:>> wrote:
>
>> On Sun, Apr 26, 2020 at 2:48 PM <navee...@gmail.com <javascript:>> wrote:
>>
>>> https://play.golang.org/p/e22ufH-T2M1
>>>
>>> This is my sample data structure.
>>>
>>> package main
>>>
>>> import (
>>> "fmt"
>>> )
>>>
>>> type MicroChkpt struct {
>>> comprtype uint32
>>> MicroChkptInfoMap map[uint32][]byte
>>> }
>>>
>>> type CallChkpt struct {
>>> FullChkptData []byte
>>> MicroChkptMap map[uint32]*MicroChkpt
>>> ckey uint32
>>> comprtype uint32
>>> AuditInProgress bool
>>> }
>>>
>>> var CallChkptMap map[uint32]*CallChkpt
>>>
>>> func main() {
>>> fmt.Println("Hello, playground")
>>> }
>>>
>>> So its a nested map structure, 
>>> CallChkptMap->MicroChkptMap->MicroChkptInfoMap
>>> So i was expecting on deleting an entry from the top level map 
>>> CallChkptMap, whole underlying memory used by nested maps would be 
>>> reclaimed.
>>>
>>> Its not happening till all entries are removed from the top level map( 
>>> then only i see memory dipping), map has ongoing insert and delete 
>>> operations and grows pretty big.
>>> Any workarounds to reclaim the memory on deleting the specific entry 
>>> please?
>>>
>>>
>>> Should i go to the nested maps first, set them to nil and then delete 
>>> the entry from the top level map?
>>> Appreciate all your time and inputs.
>>>
>>
>>
>> How exactly are you measuring whether the memory has been garbage 
>> collected?
>>
>> Ian
>>
>

-- 
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/30983954-fb19-4011-a51b-65a994f59f39%40googlegroups.com.

Reply via email to