Hi Thierry,
I experimented a little bit with RAM allocation. I found some interesting (to me) details.
IDL>a = findgen(60000000)
IDL>a = findgen(80000000)
% Unable to allocate memory: to make array.
% Execution halted at: $MAIN$
IDL>b = findgen(20000000)
IDL>c = findgen(20000000)
; At this point, we do have 100 mln total!
IDL>a = ''
IDL>b = ''
IDL>c = ''
IDL>a = findgen(100000000)
% Unable to allocate memory: to make array.
% Execution halted at: $MAIN$
Why is this happening? Reassigning a larger array to an already large variable does not work, but adding another variable reaching the same memory size does. Well, I guess IDL tries to allocate 80 mln pts before releasing the first 60 mln. But how having three arrays with the total of 100 mln points works, but having one of this size does not, beats me. Given that this is happening at all on the Mac Classic is amazing. But it is working kind of funny. I think this behavior also is not known to anybody.
Thank you,
Pavel
Hi Pavel,
I don't really remember what order IDL does everything, but the reason you are finding it easier to allocate the same amount of total memory in small chunks than in one big block is due to memory fragmentation.
Let's say you have 10MB of free contiguous space.
You allocate 5MB then 1MB then 4MB
Now you free the 5MB and 4MB allocations.
You now have 9MB available but 5MB is the largest allocation possible since the older 1MB allocation has now fragmented your memory.
Over time, all program heaps become fragmented. Mac OS X (and UNIX in general) kind of skirts around the problem somewhat by using the entire 4GB virtual address space for any given app.
Thierry