You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The off heap memory will not reclaimed, even the program has free all used memory.
This is a simplify test case, the test case run as following steps
1 allocate lots memory, such as 4GB
check the runtime memory stats , the memory is used as expectd.
check /proc//numa_maps, the memory is used as expectd.
2 release all allocated memory
check the runtime memory stats, the heap memory has returned to OS.
check /proc//numa_maps, off-heap memory (anon-rss expect c000000000 vma) still consume lots memory, even I tried with runtime.GC, debug.FreeOSMemory, and sleep long time.
The memory is released to the operating system over time. It is not released immediately, because there is a reasonable chance that a program that needs a lot of memory at one point will soon need a lot of memory again. The mechanism that releases unused heap memory to the OS is called the heap scavenger, and you can use GODEBUG=scavtrace=1 to see what it does.
The memory is released to the operating system over time. It is not released immediately, because there is a reasonable chance that a program that needs a lot of memory at one point will soon need a lot of memory again. The mechanism that releases unused heap memory to the OS is called the heap scavenger, and you can use GODEBUG=scavtrace=1 to see what it does.
I am not mean heap memory, please see my test case, the heap memory has been released after I free the allocated memory, also I called runtime.GC and debug.FreeOSMemory in my test case, and I tried with about 120second wait.
From the numa_maps, you could easily find heap memory allocated and freed as expected.
Now I mean off-heap memory, which I this is used for heap memory management, maybe memory used by GCSys / MSpanInuse.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
The off heap memory will not reclaimed, even the program has free all used memory.
This is a simplify test case, the test case run as following steps
1 allocate lots memory, such as 4GB
check the runtime memory stats , the memory is used as expectd.
check /proc//numa_maps, the memory is used as expectd.
2 release all allocated memory
check the runtime memory stats, the heap memory has returned to OS.
check /proc//numa_maps, off-heap memory (anon-rss expect c000000000 vma) still consume lots memory, even I tried with runtime.GC, debug.FreeOSMemory, and sleep long time.
Test case
sourceTest case
OutputWhat did you expect to see?
Runtime should reclaim off-heap memory (anon-rss expect c000000000 vma), when the application has freed all memory.
What did you see instead?
The off-heap memory did not reclaimed.
The text was updated successfully, but these errors were encountered: