Potential memory leak in MultipartWriter._upload_next_part
See original GitHub issueMultipartWriter._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() :
self._buf.seek(0)
part = self._mp.Part(part_num)
upload = _retry_if_failed(functools.partial(part.upload, Body=self._buf))
self._parts.append({'ETag': upload['ETag'], 'PartNumber': part_num})
logger.debug("upload of part #%i finished" % part_num)
self._total_parts += 1
self._buf = io.BytesIO()
after upload the bytesIO, not clean the Memory.
bug fix code
self._buf.seek(0)
part = self._mp.Part(part_num)
upload = _retry_if_failed(functools.partial(part.upload, Body=self._buf))
self._parts.append({'ETag': upload['ETag'], 'PartNumber': part_num})
logger.debug("upload of part #%i finished" % part_num)
self._buf.truncate()# clean the Memory , avoid Memory leak
self._total_parts += 1
self._buf = io.BytesIO()
Versions
python 3.7 smart_open 2.0.0
Checklist
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Potential memory leak? - c++ - Stack Overflow
It seems to me that, later, we cannot releasing all the spaces that is allocated to original char *str. Is this right?
Read more >Configuring the memory leak policy - IBM
You can configure a leak detection, prevention, and action policy to accommodate your applications and environment so that potential memory leaks are ...
Read more >Understanding Memory Leaks in Java - Baeldung
Memory leaks are a genuine problem in Java. In this tutorial, we'll learn what the potential causes of memory leaks are, how to...
Read more >Tutorial: Find a memory leak | IntelliJ IDEA Documentation
Memory leak is visible on CPU and Memory Live Charts ... That's ten base images that correspond to the possible positions of the...
Read more >How to Detect Memory Leaks in Java: Causes, Types, & Tools
Excessive usage of static fields can potentially lead to a memory leak. In Java, static fields usually remain in memory as long as...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
wouldn’t the garbage collector take care of this? em, i use smart_open in High concurrency and high throughput distributed system. wait the garbage collector(python’s) to deal it is not good idea. I suppose to recycle the memory by self. I will try to recycle the memory by self, later i write the result at here. Thanks!
@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.