-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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 cannot be released when receiving files in form-data #3564
Comments
The iox.DupReadCloser() function is called in the LogHandler() function in the rest/handler/loghandler.go file,The content of this function is:
This function consumes a lot of memory. |
I'm sure I'm checking the memory in use:
traces:
According to my testing, there are actually two problems:
I suggest you observe it during the upload process or immediately after the upload is completed. In addition to pprof, you can also use the Windows Resource Monitor or the Linux command line to observe the memory changes of the process. |
i meet this problem too! |
@kevwan I can reproduce the issue. Specifically, my investigation revealed that the |
Describe the bug
I created a handler to receive files uploaded by clients. In the handler, I used the ParseMultipartForm function to set the maximum memory, and used FormFile to receive files and write them locally. However, during the debugging process, I found that the memory occupied by the Buffer could not be released. The strange thing is that this doesn't happen when I create an http server using net/http, I'm not sure if this problem is related to go-zero.
To Reproduce
The memory allocation analyzed by pprof is as follows:
Memory allocation when using net/http is as follows:
Expected behavior
Please confirm if this problem is related to go-zero, and how can I receive a large file using less memory?
Screenshots
If applicable, add screenshots to help explain your problem.
Environments (please complete the following information):
More description
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: