Why can I no longer make an array of this size?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ben Hendrickson
am 2 Aug. 2017
Kommentiert: Ben Hendrickson
am 2 Aug. 2017
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 Kommentare
Akzeptierte Antwort
Jan
am 2 Aug. 2017
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 Kommentare
John D'Errico
am 2 Aug. 2017
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Import and Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!