In MATLAB's user guide, there is one page named 'Strategies for Efficient Use of Memory'. I found one paragraph 'Long-Term Usage (Windows Systems Only)' says:
On 32-bit Microsoft Windows, the workspace of MATLAB can fragment over time due to the fact that the Windows memory manager does not return blocks of certain types and sizes to the operating system. Clearing the MATLAB workspace does not fix this problem. You can minimize the problem by allocating the largest variables first. This cannot address, however, the eventual fragmentation of the workspace that occurs from continual use of MATLAB over many days and weeks, for example. The only solution to this is to save your work and restart MATLAB.
Is that means that the only way I can deal with this problem is using 64-bit windows or Linux? Thanks a lot.
No products are associated with this question.
Might I ask why moving to 64-bit Windows is a problem? 64-bit variants of Windows have existed in the Server line for some time, as well as XP, Vista and of course, 7. Commodity hardware has supported 64-bit for some time, as well.
The other option is to save your work and restart MATLAB, as stated in the guide.
If you are working on a system that's going to be in use for a long period of time, keep in mind that you should design for that system to go down and be able to restart it's work, independent of the operating system. Systems will need to be taken down for many reasons, both planned and unplanned. Patch installations, OS upgrades, hardware failure, power failure, OS crashes and just the passage of time all will cause an outage at one point or another, and it should be considered how much data is acceptable to lose -- or how to pick up processing where you left off.
64 bit systems to not actually solve this problem, but because of the much larger virtual address space available it is not an issue. In a worst case scenario an application will need twice the virtual address space as ram that it will use so an application that needs less then 1gb ram will never have issues on 32 bit systems.
If an application never uses large (many megabyte) arrays or allocates them and does not grow or free them then this will never be an issue.
Applications that hit this first are those that build large arrays by reading in and appending data to an array one chunk at a time. The best way to avoid an issue is to keep smaller objects in a cell array or other data structure. For instance instead of storing a sequence of images in a a 3d array store 2d images in a cell array of images.