Open wwse opened 5 years ago
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.
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.
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.
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)