Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed memory leak when display multframe, share for everyone,want to help others #538

Open
mingBee opened this issue Feb 23, 2024 · 0 comments

Comments

@mingBee
Copy link

mingBee commented Feb 23, 2024

when I use cornerstone to display multframe and scroll to change, The memory increase very fast .
I found the reason is possMessage to worker, transfer param do not add and the type of pixelData param is Unit8, not arraybuff.
I change like this:

eefca0df38e62ae123902ffbfa5fe14

cornerstoneWADOImageLoader.js
processDecodeTask method 831 line
function processDecodeTask(imageFrame, transferSyntax, pixelData, options) {
let passs_pixelData = new Uint8Array(pixelData.slice(0)); //copy pixelData, pass worker not clear data ,new .. prevent .buffer error
var priority = options.priority || undefined;
// var transferList = options.transferPixelData ? [passs_pixelData.buffer] : undefined;
var transferList = [passs_pixelData.buffer]; //worker transfer
var loaderOptions = (0, _options.getOptions)();
var strict = loaderOptions.strict,
decodeConfig = loaderOptions.decodeConfig,
useWebWorkers = loaderOptions.useWebWorkers;

if (useWebWorkers === false) {
if (codecsInitialized === false) {
(0, _decodeJPEG.initializeJPEG2000)(decodeConfig);
(0, _decodeJPEGLS.initializeJPEGLS)(decodeConfig);

  codecsInitialized = true;
}

return new Promise(function (resolve, reject) {
  try {
    var decodeArguments = [imageFrame, transferSyntax, passs_pixelData, decodeConfig, options];
    var decodedImageFrame = _decodeImageFrame2.default.apply(undefined, decodeArguments);

    (0, _calculateMinMax2.default)(decodedImageFrame, strict);

    resolve(decodedImageFrame);
  } catch (error) {
    reject(error);
  }
});

}

return _webWorkerManager2.default.addTask('decodeTask', {
imageFrame: imageFrame,
transferSyntax: transferSyntax,
pixelData: passs_pixelData.buffer, //pass buffer,make transfer effect
options: options
}, priority, transferList).promise;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant