Hello,
I was trying to find a memory leak in my application, but now I think either it is in HTTP.jl or I’m doing some thing wrong…
I created a test script to reproduce the issue (replace “path/to/a/large/file.iso” to some large test file on your system to reproduce):
using HTTP, Profile
function example(req::HTTP.Request)
@info "request handling: \"Ping!\""
return HTTP.Response(201, "Ping!")
end
const router = HTTP.Router()
HTTP.register!(router, "POST", "/", example)
@info "start server"
HTTP.serve!(router, HTTP.Sockets.localhost, 8080)
@info "send POST request"
data = Dict(
"label" => "Large File",
"file" => HTTP.Multipart("dvd_image.iso", open("path/to/a/large/file.iso"), "application/octet-stream")
)
body = HTTP.Form(data)
HTTP.request("POST", "http://127.0.0.1:8080/", [], body)
@info "force GC run"
GC.gc()
@info "create heap snapshot"
Profile.take_heap_snapshot("mem.heapsnapshot")
After executing this, I still see the file I sent via the HTTP POST request taking all the memory:
The memory of the request payload should be released after the handler function returns, shouldn’t it?
Can anyone help, is this a HTTP.jl issue or am I using it wrong?