Out of memory problem

When I need do image processing, I always have memory shortage problem. By using 'memory' or increasing virtual memory doesn't work. How can I use some functions like 'malloc' to allocate more memories to several image matrix which could be 512x512x200? Thanks.
James

回答(3 个)

Sean de Wolski
Sean de Wolski 2011-6-17

0 个投票

Even of class double a 512x512x200 matrix is only 419430400 bytes - hardly very much in today's world. How many other variables do you have? Are you on a 64bit system? It might pay to upgrade.

4 个评论

The computer is a 32bit Windows XP. I have four of this kind of matrix.
The following is what I got from 'memory' command:
Maximum possible array: 275 MB (2.881e+008 bytes) *
Memory available for all arrays: 1154 MB (1.210e+009 bytes) **
Memory used by MATLAB: 623 MB (6.533e+008 bytes)
Physical Memory (RAM): 3543 MB (3.715e+009 bytes)
* Limited by contiguous virtual address space available.
** Limited by virtual address space available.
Thanks.
James
Upgrade to 64bit with more RAM...
If that's not an option, what class are you variables>
class(x)
?
And you could always downsample; a downsampling of two in each dimension will reduce the amount of memory needed by 7/8
I already changed the data type from 'double' to 'single'. The problem is no 'contiguous virtual address space available'. How can I pack the dynamic allocate 'memory'?
(no update to 64bit OS option) Thanks.
James
I'm not on Windows, sorry. What about downsampling?
x = x(1:2:end,1:2:end,1:2:end);

请先登录,再进行评论。

Try
pack
Based on your comments to Sean de, I think there is something else going on. When do you run the memory command? If I clean boot my machine (WinXP 32 bit) and start MATLAB I get:
Maximum possible array: 1224 MB (1.283e+009 bytes) *
Memory available for all arrays: 1548 MB (1.624e+009 bytes)
Memory used by MATLAB: 250 MB (2.620e+008 bytes)
Physical Memory (RAM): 1976 MB (2.072e+009 bytes)

2 个评论

I used the 'pack' and the problem is still there. Thanks.
From your comments to Sean de, you have 3.5 GB of RAM after the 32 bit OS eats 0.5 GB. MATLAB takes 0.5 GB and reports 1 GB free after. Where did the other 2 GB go? If I don't run anything else, Windows takes 0.5 GB, so you are still missing 1.5 GB. What else is running on your computer. If the 1.5 GB of memory used by that stuff is all over the place, the remaining 1 GB that MATLAB has access to will be fragemented, and MATLAB cannot do anything about it.

请先登录,再进行评论。

Gurudatha Pai
Gurudatha Pai 2011-6-17

0 个投票

What is the OS virtual memory setting on your machine? on WinXP see My Computer--> Properties --> Advanced Tab --> Change button Virtual Memory Box.
It should show you the maximum allowed (also minimum and recommended) virtual memory on each drive! Mine is on 'System managed size'. This setting works for me very nicely (Matlab 2011a, WinXP SP3) and I have 6651MB of virtual memory on each of the three drives.

1 个评论

I once set the virtual memory to 32000M bytes and later I realized the maximum is 4000M bytes for 32 bits OS. I tried to set a large one (like the 32000M), that doesn't work. Thanks.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Numeric Types 的更多信息

标签

提问:

2011-6-17

Community Treasure Hunt

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

Start Hunting!

Translated by