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

Cannot enlarge memory arrays. #338

Open
HolgerWillems opened this issue May 20, 2020 · 11 comments
Open

Cannot enlarge memory arrays. #338

HolgerWillems opened this issue May 20, 2020 · 11 comments

Comments

@HolgerWillems
Copy link

I don't succeed in uploading a 800MB DICOM file to paraview-glance because of memory issues. How can I upload these larger files, without upgrading my RAM or VRAM? Thank you!

Error on a development server on Windows 10, 16GB RAM, 8GB VRAM:

Cannot enlarge memory arrays. Either (1) compile with  -s TOTAL_MEMORY=X  with X higher than the current value 1694498816, (2) compile with  -s ALLOW_MEMORY_GROWTH=1  which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with  -s ABORTING_MALLOC=0

Error on Ubuntu 18.04, 32GB RAM, 11GB VRAM:

Exception thrown while writing the image itkDICOMImageSeriesReaderJSBindingWasm.js:9:28594
<empty string> itkDICOMImageSeriesReaderJSBindingWasm.js:9:28594
itk::MemoryAllocationError (0x956ed0) itkDICOMImageSeriesReaderJSBindingWasm.js:9:28594
Location: "unknown" itkDICOMImageSeriesReaderJSBindingWasm.js:9:28594
File: /ITK/Modules/Core/Common/include/itkImportImageContainer.hxx itkDICOMImageSeriesReaderJSBindingWasm.js:9:28594
uncaught exception: Object
Line: 192 itkDICOMImageSeriesReaderJSBindingWasm.js:9:28594
Description: Failed to allocate memory for image. itkDICOMImageSeriesReaderJSBindingWasm.js:9:28594
<empty string> 2 itkDICOMImageSeriesReaderJSBindingWasm.js:9:28594
@floryst
Copy link
Collaborator

floryst commented May 21, 2020

Hi! Seems like you're running up against whatever memory allocation is set for itk.js. @thewtex Do you encounter this issue when you first select your dataset, or after you hit "Load"?

While Glance isn't really meant to view really large datasets due to constraints set by the browser, it should probably work with your Ubuntu machine specs. I don't have an ~800MB dataset on hand right now to see if I can reproduce the issue, but I have loaded 1GB of DICOM data (multiple series) into itk.js before.

@HolgerWillems
Copy link
Author

Good to hear that it could be able to work. I encounter this issue while selecting the DICOM. The load button doesn't become active.

@floryst
Copy link
Collaborator

floryst commented May 21, 2020

Is your data a single series, or multiple series? Multiple files, or one single (multi-frame) file? I might get a better idea of where to look if I know this info.

@thewtex
Copy link
Member

thewtex commented May 22, 2020

@floryst this could likely be resolved, along with faster loading, with your WIP that enables separate series sorting / loading. In this case the pixel data is loaded incrementally, in slabs, in parallel, reducing memory usage.

@HolgerWillems
Copy link
Author

@floryst Good suggestion, for practical reasons I always use the single file format. I now also tried the multiple files format and this worked on my 16GB RAM Windows machine. Selecting the file was slow, but once loaded, the interaction was quite fast. So the issue is related to 800MB DICOM single file format, as e.g. 250MB single file format works perfectly.

@thewtex
Copy link
Member

thewtex commented May 22, 2020

If it is a single, multi-frame file, it may help if glance used itk/readImageFile instead of the series reader as indicated by:

itkDICOMImageSeriesReaderJSBindingWasm.js

@HolgerWillems
Copy link
Author

Thank you very much for these useful suggestions! I succeeded in uploading a single Dicom file of 800MB with itk/readImageFile, while also keeping the original multifile upload.

I added it like this in my code in ITKReader/ITKDicomImageReader.js.:

  publicAPI.readFileSeries = (files) => {
    if (!files || !files.length || files === model.files) {
      return Promise.resolve();
    }

    model.files = files;
    let promise = null;

    if (files.length === 1) {
      promise = readImageFile(null, files[0]);
    } else {
      promise = readImageDICOMFileSeries(null, files);
    }

@floryst
Copy link
Collaborator

floryst commented May 25, 2020

That's great! I'm sure others can benefit from what you've added, so if you submit a PR to Glance I can review and merge your changes. :)

@HolgerWillems
Copy link
Author

Hi, unfortunately, I am not able to integrate this patch in the most recent version of ParaView-glance as I only fixed it for the older version of "itk": "10.2.1" .

With the new version of "itk": "12.2.0" I experience the problems for 800MB files as stated earlier (see following error), but now for both single file and for multiple file DICOM and the fix doesn't work. It could be that I switch in the future to the newer version of ITK and can perhaps look deeper into it. In any case, thank you!

Exception thrown while writing the image itkDICOMImageSeriesReaderJSBindingWasm.js:9:28594
<empty string> itkDICOMImageSeriesReaderJSBindingWasm.js:9:28594
itk::MemoryAllocationError (0x94d058) itkDICOMImageSeriesReaderJSBindingWasm.js:9:28594
Location: "unknown" itkDICOMImageSeriesReaderJSBindingWasm.js:9:28594
File: /ITK/Modules/Core/Common/include/itkImportImageContainer.hxx itkDICOMImageSeriesReaderJSBindingWasm.js:9:28594
Line: 192 itkDICOMImageSeriesReaderJSBindingWasm.js:9:28594
Description: Failed to allocate memory for image. itkDICOMImageSeriesReaderJSBindingWasm.js:9:28594

@floryst
Copy link
Collaborator

floryst commented May 26, 2020

Oh, hm that might be the switch from workerfs to memfs for itk.js virtual filesystem. Will have to investigate further to see how we can handle large files.

@thewtex
Copy link
Member

thewtex commented Jun 1, 2020

Line: 192 itkDICOMImageSeriesReaderJSBindingWasm.js:9:28594

This is indicating that we are not yet using itk/readImageFile.

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

3 participants