Sign in

http.Get Memory leak for

Ankur edited in Tue, 13 Sep 2022
func main() {
    go GetTest()
    select {}

func GetTest() {
    for {
        resp, ok := http.Get("http://localhost/index.php")
        if ok != nil {

        time.Sleep(1 * time.Second)

I send a get request every one second in a coroutine, and then close the body. However, the memory of this program is increasing all the time. What kind of resources have not been released?

1 Replies
commented on Tue, 13 Sep 2022

This looks like there is no GC, the memory accumulated for a period of time to do garbage collection.