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

RangeError: Array buffer allocation failed in DicomParser.js (getTypedArray) #654

Open
wwse opened this issue Apr 25, 2019 · 2 comments
Open
Labels
question Further information is requested
Milestone

Comments

@wwse
Copy link

wwse commented Apr 25, 2019

I am using DWV Viewer in my mobile app using web view.
When I load around 200 Dicom files, an error pops as RangeError: Array buffer allocation failed
The error comes in getTypedArray() of DicomParser.js. This method is called from Image.js.
It happens due to the buffer size increasing with each slice. This shoots up the mobile memory and hence the error comes.

    var newBuffer = dwv.dicom.getTypedArray(
        buffer[f].BYTES_PER_ELEMENT * 8,
        meta.IsSigned ? 1 : 0,
        sliceSize * (size.getNumberOfSlices() + 1) );

The size passed to getTypedArray is 36175872.

Can you please help on how we can change/improve this?

Log trace:

RangeError: Array buffer allocation failed
at new ArrayBuffer ()
at new Int16Array (native)
at Object.dwv.dicom.getTypedArray (http://localhost:4300/assets/third_party_js/dwv/src/dicom/dicomParser.js:795:19)
at dwv.image.Image.appendSlice (http://localhost:4300/assets/third_party_js/dwv/src/image/image.js:365:35)
at dwv.image.View.append (http://10.6.6.117:4300/assets/third_party_js/dwv/src/image/view.js:449:45)
at dwv.image.DicomBufferToView.loader.onload (http://localhost:4300/assets/third_party_js/dwv/src/app/application.js:635:22)
at onDecodedFirstFrame (http://localhost:4300/assets/third_party_js/dwv/src/image/dicomBufferToView.js:64:18)
at dwv.image.DicomBufferToView.convert (http://localhost:4300/assets/third_party_js/dwv/src/image/dicomBufferToView.js:151:13)
at dwv.io.DicomDataLoader.load (http://localhost:4300/assets/third_party_js/dwv/src/io/dicomDataLoader.js:73:18)
at XMLHttpRequest.__zone_symbol__ON_PROPERTYload (http://localhost:4300/assets/third_party_js/dwv/src/io/dicomDataLoader.js:125:18)

@ivmartel ivmartel added the question Further information is requested label Apr 26, 2019
@ivmartel
Copy link
Owner

I had a look and it is not that easy to check the available amount of memory before trying to load the data. This amount varies among browsers and I cannot find a page that clearly says how it is set/calculated.

There are non standard tools such as performance.memory on Google Chome that could help debug your issue. See monitoring-javascript-memory.

Relates to #342.

@ivmartel ivmartel added this to the Future milestone Apr 26, 2019
@wwse
Copy link
Author

wwse commented Apr 26, 2019

The logic that is used for creating the buffer, why is the size not considered per slice?
As the size increases with every slice loaded. So if I have 200 URLs to load, the size multiplies and results in a large number.

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

No branches or pull requests

2 participants