Linux RSS infintely increasing though go heap is empty #41
Comments
func main() {
initPython()
for {
//Infinite loop, make some data and create python dict
message := createMessage()
messageDict := getPyDict(message)
messageDict.Clear()
messageDict.Decref()
}
} that's because see: hth, (feel free to reopen if something's astray) |
Nope. Made no difference. Still the same, even after enabling Python GC manually via their API https://docs.python.org/2/library/gc.html (called gc.enable() function). |
you're right. there are 2 other errors, leading to memory leaks:
with these modifications, the following program: package main
import python "github.com/sbinet/go-python"
func main() {
initPython()
for {
//Infinite loop, make some data and create python dict
message := createMessage()
messageDict := getPyDict(message)
python.PyDict_Clear(messageDict)
messageDict.DecRef()
}
}
func createMessage() map[string]interface{} {
payload := make(map[string]interface{})
payload["key_1"] = "value_1"
payload["key_2"] = "value_2"
payload["key_3"] = "value_3"
return payload
}
func getPyDict(message map[string]interface{}) *python.PyObject {
messageDict := python.PyDict_New()
for key, value := range message {
pyKey := python.PyString_FromString(key)
pyValue := python.PyString_FromString(value.(string))
python.PyDict_SetItem(messageDict, pyKey, pyValue)
pyKey.DecRef()
pyValue.DecRef()
}
return messageDict
}
func initPython() {
//Init Python
if err := python.Initialize(); err != nil {
panic(err)
}
} stabilizes at |
Cool. Works !!!. Thanks a lot, have been struggling with this for a while. I see that there is no corresponding function |
yes. |
Noticed that |
Hi,
I'm not sure what exactly is happening here but the resident memory occupied by the golang process never seems to get free though there is nothing in the heap. Here is a sample code:
The above script takes 1GB of RSS within a minute and the memory usage keeps increasing and doesn't seem to go down (golang heap is 0MB). Here are my local box details:
uname -a
go version
go env
The text was updated successfully, but these errors were encountered: