cornerstonejs / cornerstoneWADOImageLoader

[DEPRECATED] DICOM WADO Image Loader for the cornerstone library
MIT License
280 stars 266 forks source link

Web Workers: Double the expected memory usage #225

Open novakoki opened 5 years ago

novakoki commented 5 years ago

Here are some memory snapshots below:

  1. cornerstoneWADOImageLoader live example with a single instance of compressed dicom file image compressed size: about 300KB (Uint8Array) uncompressed size: about 512KB (UInt16Array) We can also find the two ArrayBuffer use different memory addresses.

  2. A series of dicom instances, compressed, with cornerstoneWADOImageLoader@2.1.4, using web worker image instance size: 191 ideal memory utilization: 191 512KB ~ 95MB actual memory utilization: 191 512KB (uncompressed) + 191 * 300KB (compressed) ~ 150MB

  3. The same series above, but with cornerstoneWADOImageLoader@0.13.3, the last version without web worker image image image We can also find the two ArrayBuffer use the same memory address.

And if the original dicom file is uncompressed, it cost double size of all instances.

In my opinion, web worker or codecs may be the key point, but I could not find where the problem is in source code.

dannyrb commented 5 years ago

Thanks for the report, @novakoki. FWIW, as a temporary workaround, we've been able to free up space by periodically killing workers (after processing X tasks), or when the task queue gets low.

This issue will likely end up in a web-worker + memory improvement round up as we clean up these issues.