Skip to content

Commit fb3abfa

Browse files
authored
Merge pull request #26 from claydugo/fixup_memory_leak
Address memory leak in `imwrite_to_memory()`
2 parents 5d8a889 + f5b2fc9 commit fb3abfa

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.6.1] - 2026-01-23
9+
10+
- Fix memory leak in `imwrite_to_memory()`. The codestream and memory outfile are now
11+
properly closed after encoding.
12+
13+
14+
815
## [0.6.0] - 2026-01-22
916

1017
- Provide a new method `get_level_shape` to help get the shape after decoding for

ojph/_imwrite.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ def imwrite_to_memory(
5757
tileparts_at_resolutions=tileparts_at_resolutions,
5858
tileparts_at_components=tileparts_at_components,
5959
)
60-
return np.asarray(CompressedData(mem_outfile, codestream))
60+
data = bytes(mem_outfile.get_data())
61+
codestream.close()
62+
mem_outfile.close()
63+
return np.frombuffer(data, dtype=np.uint8)
6164

6265

6366
def imwrite(

0 commit comments

Comments
 (0)