Failed to allocate memory Error

I was trying to execute the DeformableRegistration15.cxx on two brain CT images.
Pixel Type is short. I get this error when i execute it.
Please help me with thins.

I’m sorry I don’t have the answer, but I just wonder:

  1. How large are these two CT images? How large are the actual CT files?
  2. Did you compile for 32-bit (x86) or 64-bit (x64)? Debug or Release?
  3. Which version of ITK do you use?

Good luck!

2 Likes

That error message indicates that the images are too big for your computer’s memory. You could try increasing your swap file size.

1 Like

Hi,

I encounter a similar problem and was wondering how to solve by using your questions:

  1. I am using 4D MR images that are around 1500 MB
  2. I compiled for 32-bit, Release, using Visual Studio 2017
  3. I am using ITK 4.8

I know that it is an old version of Visual Studio and an old version of ITK, but I need this because other tooling I use is based on these old versions. Compiling for 64-bit, following How to: Configure Visual Studio C++ projects to Target 64-Bit, x64 Platforms | Microsoft Learn, did not work as my Visual Studio application keeps freezing when I try to do this after loading my .sln file…

I also already increased my swap file size to a range of 10000 to 70000 MB, as suggested below.

But I am still running into problems.

Normally, 32-bit Windows reserves 2GB of user-space memory for system use. I think that policy was abandoned sometime, but there is still memory fragmentation, which makes allocating 1.5GB image far from a sure thing.

I switched to compiling for 64-bit address space long before Visual Studio 2017 came around. I don’t remember any particular issues with it. We did recently drop support for VS2017, so if you insist on using it, use a bit older version of ITK such as 5.3 or 5.2. The best way to build is the usual CMake process. Just make sure to pick the 64-bit toolset. If your VS is freezing when opening a solution, you might need to have more RAM in your computer. If that is not an option, try opening “C:\Dev\ITK-build\Examples\RegistrationITKv4\ITKv4ImageRegistration.sln” instead of “C:\Dev\ITK-build\ITK.sln”.