http.Request.FormFile()接收文件后内存不立即释放的问题

//go 1.3
func uploadHandler(w http.ResponseWriter, r *http.Request){
        fn,header,_:=r.FormFile("file")
        defer fn.Close()

        f,_:=os.Create(header.Filename)
        defer f.Close()

        io.Copy(f,fn)
}

发现上传文件后内存不能立即释放,短时间上传几个大文件很容易就出现err:cannot map pages in arena address space,请问要如何使uploadHandler()结束后立即释放内存.

共 1 个回复


chenhao

有人提议用runtime.SetFinalizer,但是不会.

# 0