-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #167 from pycompression/readallmemoryleak
Fix memory leak in GzipReader.readall
- Loading branch information
Showing
4 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import gc | ||
import resource | ||
import sys | ||
|
||
from isal import igzip | ||
|
||
for _ in range(10): | ||
with igzip.open(sys.argv[1], "rb") as reader: | ||
a = reader.read() | ||
print(len(a)) | ||
gc.collect() | ||
memory_usage = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss | ||
memory_usage_mb = memory_usage / 1024 | ||
print(f"Maximum memory usage: {memory_usage_mb:.2f} MiB") | ||
del a | ||
objects_and_size = [(sys.getsizeof(obj), type(obj)) for obj in | ||
gc.get_objects()] | ||
objects_and_size.sort(key=lambda x: x[0], reverse=True) | ||
print(objects_and_size[:10]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters