Why can I no longer make an array of this size?
1 次查看(过去 30 天)
显示 更早的评论
I use Matlab to look at time based signals from a CMOS image sensor. To do that, I take 1500 frames, and stack them together to make one time based signal for each pixel (~5M). I've never had an issue doing this before, but suddenly, I'm not allowed. I understand that 56G of allocated memory is ridiculous, but somehow I was able to do this in the past. Any ideas?
The code shown here is essentially identical to an older file that worked.
% tic;
stacknum = 1500;
imagewidth=2592;
imageheight=1944;
pixel = uint16(zeros(imagewidth,imageheight,stacknum));
for i=1:stacknum
data = data.';
filename=sprintf('frame_%d.mat' ,i); %name files one at a time
load(filename);
pixel(:,:,i) = data(:,:);
end
fname = sprintf('A2_stack_32C.mat'); %name the data file
save(fname,'-v7.3');
sound(randn(409, 1), 8192)
toc;
I've included a loaded array, created a while ago, to show that I'm not straight up lying.

2 个评论
采纳的回答
Jan
2017-8-2
zeros(imagewidth, imageheight, stacknum)
creates a 60.5GB array, but casting it afterwards requires an additional 15.1GB array, before the zeros of type double are removed. Better use:
pixel = zeros(imagewidth, imageheight, stacknum, 'uint16');
which creates the 15.1GB array directly without wasting memory.
I understand that 56G of allocated memory is ridiculous, but somehow I was able to do this
in the past. Any ideas?
If this has worked in the past, you had a machine with more than 75GB of free RAM. I cannot guess, where or when this memory has been gone.
Note:
save(fname,'-v7.3');
cases all variables to the MAT file, including "i", "fname", the magic "data" (coming from the useless "data = data.'" line. Better define explicitely, what should be saved in this file.
sound(randn(409, 1), 8192)
? Brrr, sounds ugly.
2 个评论
John D'Errico
2017-8-2
My guess is in the past there was more free disk space available, which allowed Ben to create a large array of that size using virtual memory. Since then, the virtual memory block allocated on the hard disk now has less room, so no 56GB array anymore. Just a guess though.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!