Hi, I have trouble using FreeSurfer Importer provided with the SlicerFreSurfer extension.
Problem: When I try to load segmentation, it cuases bad_alloc error. The error message is below.
“Slicer has caught an application error, please save your work and restart.\n\nThe application has run out of memory. Increasing swap size in system settings or adding more RAM may fix this issue.\n\nIf you have a repeatable sequence of steps that causes this message, please report the issue following instructions available at https://slicer.org\n\n\nThe message detail is:\n\nException thrown in event: std::bad_alloc”
QXcbConnection: XCB error: 3 (BadWindow), sequence: 4707, resource id: 14695233, major code: 40 (TranslateCoords), minor code: 0
I can load Volumes (e.g. brainmask.mgz) and Models (e.g. lh.pial) without any problem. I cannot load only Segmentations.
This problem occurs only in Linux version of Slicer 5.x. I tried with both 5.0.3 and 5.2.1, and got the same error.
My workstation has 192GB RAM. Though the error message says it has run out of memory, but I feel that is not the problem.
The result of free:
$ free -h
total used free shared buff/cache available
Mem: 187Gi 41Gi 138Gi 328Mi 8.3Gi 144Gi
Swap: 2.0Gi 0B 2.0Gi
I feel there may be a bug in loading segmentation in SlicerFreeSurfer. If you have any workarounds, please let me know.
QXcbConnection: XCB error: 3 (BadWindow)... message is just a warning (seems to be a known Qt bug). Probably it is not the root cause of the serious std::bad_alloc error, but the QXcbConnection error may be triggered by the display of the modal error popup.
The memory allocation may fail because of the segmentation file contains some unexpected/misinterpreted content, which makes Slicer want to allocate an enormous amount of memory.
Can you share a data set that you have problem with and instructions for reproducing the issue?
I have not been able to reproduce this issue using the steps above in
the following setup:
OS: Ubuntu 22.04
Slicer version: 5.3.0-2022-12-03 (self-built)
Slicer revision: 31346
SlicerFreeSurfer: master branch
@kytk, you could give a try to the preview release (5.3.0) and see if it
works. From all the changes you could do to approach a working
environment, this is the easiest.
Thank you for checking. Now I know that something is wrong in my environment.
Though the preview release resulted in the same error, I will try to build Slicer for my environment and see if it works.
Chiming in late, but I am also getting this issue with 5.3.0 and Ubuntu 22.04. I did not have this issue on Windows or Mac with the same dataset and Slicer Version. It seems to throw the error specifically when loading Segmentations from FreeSurfer, I’m able to load Models and Volumes. I have plenty of free ram and swap (32gb free memory)
"Slicer has caught an application error, please save your work and restart.\n\nThe application has run out of memory. Increasing swap size in system settings or adding more RAM may fix this issue.\n\nIf you have a repeatable sequence of steps that causes this message, please report the issue following instructions available at https://slicer.org\n\n\nThe message detail is:\n\nException thrown in event: std::bad_alloc"
ReferenceImageExtentOffset attribute was not found in NRRD segmentation file. Assume no offset.
Try the latest release and preview release (5.3.0 is old at this point). Also, if the issue can be easily reproduced, please share data and exact steps that lead to the issue.