Skip to content

Commit fb34ac6

Browse files
authored
Merge pull request #168 from pycompression/release_1.5.1
Release 1.5.1
2 parents 95517bc + 0564332 commit fb34ac6

File tree

6 files changed

+34
-4
lines changed

6 files changed

+34
-4
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ Changelog
77
.. This document is user facing. Please word the changes in such a way
88
.. that users understand how the changes affect the new version.
99
10+
version 1.5.1
11+
-----------------
12+
+ Fix a memory leak in the GzipReader.readall implementation.
13+
1014
version 1.5.0
1115
-----------------
1216
+ Make a special case for threads==1 in ``igzip_threaded.open`` for writing

benchmark_scripts/memory_leak_test.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import gc
2+
import resource
3+
import sys
4+
5+
from isal import igzip
6+
7+
for _ in range(10):
8+
with igzip.open(sys.argv[1], "rb") as reader:
9+
a = reader.read()
10+
print(len(a))
11+
gc.collect()
12+
memory_usage = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
13+
memory_usage_mb = memory_usage / 1024
14+
print(f"Maximum memory usage: {memory_usage_mb:.2f} MiB")
15+
del a
16+
objects_and_size = [(sys.getsizeof(obj), type(obj)) for obj in
17+
gc.get_objects()]
18+
objects_and_size.sort(key=lambda x: x[0], reverse=True)
19+
print(objects_and_size[:10])

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def build_isa_l():
135135

136136
setup(
137137
name="isal",
138-
version="1.5.0",
138+
version="1.5.1",
139139
description="Faster zlib and gzip compatible compression and "
140140
"decompression by providing python bindings for the ISA-L "
141141
"library.",

src/isal/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@
2727
"__version__"
2828
]
2929

30-
__version__ = "1.5.0"
30+
__version__ = "1.5.1"

src/isal/isal_zlibmodule.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,14 +1995,16 @@ GzipReader_readall(GzipReader *self, PyObject *Py_UNUSED(ignore))
19951995
return NULL;
19961996
}
19971997
if (written_size == 0) {
1998+
Py_DECREF(chunk);
19981999
break;
19992000
}
20002001
if (_PyBytes_Resize(&chunk, written_size) < 0) {
20012002
Py_DECREF(chunk_list);
20022003
return NULL;
20032004
}
2004-
if (PyList_Append(chunk_list, chunk) < 0) {
2005-
Py_DECREF(chunk);
2005+
int ret = PyList_Append(chunk_list, chunk);
2006+
Py_DECREF(chunk);
2007+
if (ret < 0) {
20062008
Py_DECREF(chunk_list);
20072009
return NULL;
20082010
}
@@ -2014,6 +2016,7 @@ GzipReader_readall(GzipReader *self, PyObject *Py_UNUSED(ignore))
20142016
}
20152017
PyObject *ret = _PyBytes_Join(empty_bytes, chunk_list);
20162018
Py_DECREF(empty_bytes);
2019+
Py_DECREF(chunk_list);
20172020
return ret;
20182021
}
20192022

tox.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,24 @@ commands=
7171

7272
[testenv:benchmark-all]
7373
deps=
74+
setenv =
7475
commands=
7576
python ./benchmark_scripts/benchmark.py --all
7677

7778
[testenv:benchmark-functions]
7879
deps=
80+
setenv =
7981
commands=
8082
python ./benchmark_scripts/benchmark.py --functions
8183

8284
[testenv:benchmark-gzip]
8385
deps=
86+
setenv =
8487
commands=
8588
python ./benchmark_scripts/benchmark.py --gzip
8689

8790
[testenv:benchmark-checksums]
8891
deps=
92+
setenv =
8993
commands=
9094
python ./benchmark_scripts/benchmark.py --checksums

0 commit comments

Comments
 (0)