-
-
Notifications
You must be signed in to change notification settings - Fork 381
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
Potential memory leak in MultipartWriter._upload_next_part #511
Comments
Thank you for reporting this. self._buf.truncate() # (1)
self._buf = io.BytesIO() # (2) Interesting, wouldn't the garbage collector take care of this? We're throwing away the old value of I will investigate. Thanks again. |
wouldn't the garbage collector take care of this? em, i use smart_open in |
If you use cpython (the standard python) there is no "wait". Memory is reclaimed as soon as it's not needed = its reference count goes to zero. There are some exceptions with reference cycles but not leaks. I'd expect some other code (boto?) is holding on to the reference longer than it should. |
I'd be surprised if that's really the case. I think it's more likely the entire part (a single part of the multipart upload) is being kept in memory. The default part size is 50MB. You can tweak it by passing min_part_size as a transport_param (please see the README). Also, check out #547 - it has the option of buffering to disk instead of in memory. It's not ready to merge yet, unfortunately. |
@cnmoise Can you reproduce the problem with the newest version of smart_open? We've reworked the buffering in the S3 submodule significantly, and it's likely the problem is no longer there. |
MultipartWriter._upload_next_part Memory leak
the MultipartWriter._upload_next_part function upload the bytesIo from Memory to s3(by upload[CreateMultipartUpload]),but do not clean bytesIO (in Memory).
i use the smart_open.open() (gz file) upload to s3,the Memory Keep increasing。 I check the code and focus the MultipartWriter._upload_next_part() :
after upload the bytesIO, not clean the Memory.
bug fix code
Versions
python 3.7
smart_open 2.0.0
Checklist
https://docs.python.org/zh-cn/3/library/io.html
The text was updated successfully, but these errors were encountered: