Description
This PR includes changes that will dispose PinnedByteArray that is holding memory while doing transcoding.
Repo
Here is the sample code that will reproduce the memory being not cleaned by the garbage collection. In the sample, I am transcoding a dicom instance from Explicit VR Little Endian transfer syntax to JPEG 2000 Image Compression (Lossless Only) transfer syntax. This is because, PinnedByteArrray are not disposed while doing transcoding when using DicomJpeg2000LosslessCodec or DicomJpeg2000LossyCodec. But the same PinnedByteArray is cleaned properly in JpegNativeCodec implementation.
You can see below, when transcoding a file for 5 times, the memory stays high and not garbage collected.
From the above memory profiler, we can see that the byte[] is not garbage collected and classified by the memory profiler as "dead object".
We believe that the Gen 2 GC not happening, since it is allocated in large object heap.
Solution
Dispose PinnedByteArray
Profiler screenshot after disposing
Description This PR includes changes that will dispose
PinnedByteArray
that is holding memory while doing transcoding.Repo Here is the sample code that will reproduce the memory being not cleaned by the garbage collection. In the sample, I am transcoding a dicom instance from
Explicit VR Little Endian
transfer syntax toJPEG 2000 Image Compression (Lossless Only)
transfer syntax. This is because,PinnedByteArrray
are not disposed while doing transcoding when usingDicomJpeg2000LosslessCodec
orDicomJpeg2000LossyCodec
. But the samePinnedByteArray
is cleaned properly inJpegNativeCodec
implementation.You can see below, when transcoding a file for 5 times, the memory stays high and not garbage collected.
From the above memory profiler, we can see that the byte[] is not garbage collected and classified by the memory profiler as "dead object".
We believe that the Gen 2 GC not happening, since it is allocated in large object heap.
Solution
Testing Ran Unit and Acceptance test.