weblogs icon indicating copy to clipboard operation
weblogs copied to clipboard

memory used too larg

Open YouZhengChuan opened this issue 6 years ago • 1 comments

https://github.com/keep94/weblogs/blob/d380f9bf1ca810168b7f85c7a22fbcc18f753eeb/weblogs.go#L164

The Set method stores the "*http.Request" object in the map and does not release it actively. If the "context.Delete" delete "*http.Request" object is not displayed, memory leak will result.

YouZhengChuan avatar Aug 27 '19 09:08 YouZhengChuan

Thank you for pointing this out.

Wrapping your handler in a context.ClearHandler() should free up anything associated with the request object. Use like this:

handler := context.ClearHandler(weblogs.Handler(http.DefaultServeMux)) http.ListenAndServe(":80", handler)

If you still see memory leaking even using context.ClearHandler() please explain more.

keep94 avatar Aug 29 '19 01:08 keep94