package main
import (
"fmt"
"net/http"
"runtime"
)
func handler(w http.ResponseWriter, r *http.Request) {
largeMemAlloc := make([]int, 100000000)
largeMemAlloc[1] = 100//lol
fmt.Fprintf(w, "hi from handler")
runtime.GC()
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":7777", nil)
}
Once I visit http://127.0.0.1:7777 4-5 times the memory used goes in to GBs.
Its been around 4-5 mins and the memory is still unclaimed by the OS. Why is this happening?
What am I doing wrong?
I am compiling this in go 1.5
Edit : After 10 mins, the memory usage has gone down to just 50mb. But I dont understand why it takes so long to reclaim this block of memory. I feel like I am doing something horribly wrong.