Hi! Got a question on memory handling:
For the following script
nlon = 360; nlat = 181; nhr = 744; np = 37;
for loop = 1 : 5
@info "$(Dates.now()) - Preallocating arrays ..."
Ta = zeros(nlon,nlat,nhr,np); sH = zeros(nlon,nlat,nhr,np);
za = zeros(nlon,nlat,nhr,np); Tm = zeros(nlon,nlat,nhr);
@info "$(Dates.now()) - Extracting Surface-Level data for $(dtii) ..."
Ts = rand(nlon,nlat,nhr); Td = rand(nlon,nlat,nhr)
@info "$(Dates.now()) - Extracting Pressure-Level data for $(dtii) ..."
for pii = 1 : np; pre = p[pii];
Ta[:,:,:,pii] = rand(nlon,nlat,nhr)
sH[:,:,:,pii] = rand(nlon,nlat,nhr)
za[:,:,:,pii] = rand(nlon,nlat,nhr)
end
end
After a loop or two, my job gets killed on a cluster because the amount of memory required is too large. However, I requested 80GB of memory, so honestly I am not sure what the issue is here. Is there something I’m missing in memory handling in for
-loops?
For reference 360*181*37*24*37*3 = 6.5*10^9
which in Float64 is around 51 GB, so I’m not too sure what the issue is here because it definitely is enough memory for at least 1 loop (which is true, it does work fine for the first loop or two). But I’m just not sure if the memory carries over into next iterations. Why would this be the case?
Edit: Below is the output:
[nwong@holy7c26401 scripts]$ julia test2.jl
[ Info: 2020-04-14T18:21:27.308 - Preallocating arrays ...
[ Info: 2020-04-14T18:21:40.976 - Extracting Surface-Level data for 1 ...
[ Info: 2020-04-14T18:21:41.569 - Extracting Pressure-Level data for 1 ...
[ Info: 2020-04-14T18:22:03.337 - Preallocating arrays ...
Killed