Code ran fine previously but now says 'out of memory'

Hi all, I have used a code for years and ran it on thousands of datasets (3D medical images, size 512x512x100). now for some reason, MATLAB says out of memory at a specific point in the code when nothing has changed in the code or the type of input file/variable and its the same computer (albeit now space on C drive is super low, can that have an impact?). ran fine 2 months ago. the license did change to a different university - can that have an effect??
its running fine on smaller sized variables (124x124x100) but I've run it on much larger files many times before, no problem. rest all input variables are the similar to previously used and its a very optimized code written and published and used by several groups. what could the issue possibly be? I've tried looking everywhere.

 Accepted Answer

There is one possibility:
If you have configured Preferences -> MATLAB -> Workspace -> MATLAB array size limit
to be off, then the amount of memory that MATLAB would use would be limited by the amount of swap space that your system will provide. On Windows, the amount of swap space possible depends upon how much space is available on the C: drive (unless configured otherwise).
So, Yes, under limited conditions, having low space on C can affect how much memory MATLAB can access.

5 Comments

Thank you so much for responding. The MATLAB array size limit has the checkbox for "Limit max array size to a percentage of RAM" ON and is set to 100% .
Max array size on the top of the workspace preferences is set to 1000 and max srtuct/object nesting levels to 20.
Should this setting cause an impact and connection wit space on C drive? I'm trying to clear it but having issues with my laptop and only have like 200MB on C :(
Really appreciate your help
If you have limited array size to ram, then low space on C shouldn't affect MATLAB
... though I do wonder what the implementation is of transfering data to workers when using parfor or spmd or parfeval()... There are several potential implementations, a couple of which might be disk-backed. I doubt anything to do with this is causing your difficulties, but it would be wrong for me to say "definitely not" when there is a chance they chose an unfortunate implementation.
If you are not using parallel workers, then my mind is not coming up with any possibilities at the moment.
By the way, I recommend WinDirStat https://windirstat.net/ as a free program that is very useful in finding out what is taking up space in your drive. And consider removing old restore points; https://www.guidingtech.com/how-to-delete-system-restore-points-in-windows/
Thank you for the suggestions. I cleared up space on the C drive and also cleared some variables earlier in the code and changed things - it's working now! Not sure what the issue truly was as the code has worked for years but at least its running.
Thank you!
I have somes reclaimed a lot of space in Windows by removing old versions of windows; see https://support.microsoft.com/en-us/windows/delete-your-previous-version-of-windows-f8b26680-e083-c710-b757-7567d69dbb74
The old versions of windows are stored in a protected directory so you cannot remove them just using Windows Explorer.
(Going slightly off the topic)
They are stored so that one can restore back to the older version, mostly in the case of incompatibility e.g. if it makes the system slower, or if it causes a BSOD error. Though I was under the understanding that they were deleted after a month, maybe for newer updates it is 10 days.
The Windows Update for a good amount of time now have been extremely sluggish, and with each update completed in my PC, MATLAB takes more time to start. Sigh.

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!