itk-wasm icon indicating copy to clipboard operation
itk-wasm copied to clipboard

RuntimeError: memory access out of bounds

Open jinjilynn opened this issue 11 months ago • 6 comments

Image

those dicoms might be too large?

jinjilynn avatar Jan 24 '25 17:01 jinjilynn

It is possible that this may be a memory usage issue. More information is required.

thewtex avatar Jan 24 '25 20:01 thewtex

It is possible that this may be a memory usage issue. More information is required.

Image Image Image
async function renderDicomFileSeries(files) {
  const { outputImage, webWorkerPool, sortedFilenames } =
    await readImageDicomFileSeries({
      webWorkerPool: null,
      inputImages: files,
      singleSortedSeries: false,
    });
  console.log(outputImage);
  webWorkerPool.terminateWorkers();

  const vtkImage = vtkITKHelper.convertItkToVtkImage(outputImage);
  console.log(vtkImage);

  mapper.setInputData(vtkImage);
  renderer.addVolume(actor);
  renderer.resetCamera();
  renderWindow.render();
}

My DICOM files total 1,963 images, each with a size of 529KB. I tested it, and if I select more than 746 images from these DICOM files, no errors occur. So, does this mean that itk-wasm can handle up to a round maximum of 1GB of DICOM files?

jinjilynn avatar Jan 25 '25 15:01 jinjilynn

What are the dimensions of the image x, y, z that you are trying to read? You might be exceeding the max length limit for a JS TypedArray. As I remember, a single javascript TypedArray or ArrayBuffer cannot be larger than around 2^31.

jadh4v avatar Jan 25 '25 18:01 jadh4v

What are the dimensions of the image x, y, z that you are trying to read? You might be exceeding the max length limit for a JS TypedArray. As I remember, a single javascript TypedArray or ArrayBuffer cannot be larger than around 2^31.

you are supposed to be right, i have tried, when TypedArray got length of more than 2^27 + 61603840 , it would crash. The maximum length of an ArrayBuffer is limited by a 32-bit integer index

jinjilynn avatar Jan 26 '25 15:01 jinjilynn

I encountered this issue, too. Any solutions?

1isten avatar Jul 15 '25 00:07 1isten

I found another possible cause: if the file names are long, the error is more likely to occur.

In my test case, I loaded 1,840 DICOM files in VolView, each with a filename 40 characters long (something like "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.dcm"), and the error occurred:

Image

However, with the same files, if I shorten the filenames to something like "file-1.dcm", "file-2.dcm", etc., they load without issue.

1isten avatar Jul 15 '25 04:07 1isten