Skip to content

Commit ec7a5dc

Browse files
committed
在类被销毁时提供显示的调用回收,避免未调用GetBytes导致的_bytes未能被pool回收。
1 parent 9681513 commit ec7a5dc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Magick.NET/Helpers/ByteArrayWrapper.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ public byte[] GetBytes()
3535
_pool.Return(_bytes, true);
3636
return result;
3737
}
38-
38+
39+
~ByteArrayWrapper()
40+
{
41+
if (_bytes is not null)
42+
{
43+
_pool.Return(_bytes, true);
44+
}
45+
}
3946
#else
4047

4148
public byte[] GetBytes()
@@ -46,7 +53,6 @@ public byte[] GetBytes()
4653
}
4754

4855
#endif
49-
5056
public long Read(IntPtr data, UIntPtr count, IntPtr user_data)
5157
{
5258
if (data == IntPtr.Zero)

0 commit comments

Comments
 (0)