Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory used too larg #7

Open
YouZhengChuan opened this issue Aug 27, 2019 · 1 comment
Open

memory used too larg #7

YouZhengChuan opened this issue Aug 27, 2019 · 1 comment

Comments

@YouZhengChuan
Copy link

YouZhengChuan commented Aug 27, 2019

context.Set(r, kBufferKey, additional)

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.

@keep94
Copy link
Owner

keep94 commented Aug 29, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants