comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » memory allocation problem
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Memory allocation problem [message #64116 is a reply to message #32923] Wed, 26 November 2008 09:15 Go to previous messageGo to previous message
R.G. Stockwell is currently offline  R.G. Stockwell
Messages: 363
Registered: July 1999
Senior Member
"David Fanning" <news@dfanning.com> wrote in message
news:MPG.23972ed74e6c1fd498a566@news.giganews.com...
> Jean H. writes:
>
>> 3)divide your work!... don't use 1 big array, but 4,9 or whatever it
>> takes smaller arrays! You can easily modify the memtest program to have
>> it return the available memory.
>
> Maybe this is a dumb question, but where did you find MEMTEST?
> A search of the ITTVIS web page and user contrib sites turns
> up nothing (which, I admit, doesn't prove it's not there, but...).
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

It was posted in this group, so i guess I can repost it.


pro memtest
compile_opt idl2 ; set default integers to 32-bit and enforce [] for
indexing

MB = long64(2)^20
currentBlockSize = MB * 2047 ; 2 GB

print,'current block size = ',currentblocksize
maxIterations = 10 ; Max loop iterations
memPtrs = ptrarr(maxIterations)
memBlockSizes = ulonarr(maxIterations)

for i=0, maxIterations-1 do begin
; Error handler
catch, err

; Sepcifically designed for "Failure to allocate memory..." error
if (err ne 0) then begin
currentBlockSize = currentBlockSize - MB ; ...try 1 MB smaller
allocation
if (currentBlockSize lt MB) then break ; Give up, if currentBlockSize
< 1 MB
endif

; This 'wait' enables Ctrl-Break to interrupt if necessary (Windows).
wait, 0.0001

; Allocate memory (if possible)
memPtrs[i] = ptr_new(bytarr(currentBlockSize, /nozero), /no_copy)
memBlockSizes[i] = currentBlockSize ; Store the latest successful
allocation size

; Print the current allocated block size and the running total, in Mb
print, format='(%"Memory block #%2d: %6d Mb (total: %4d Mb)")', $
i + 1, ishft(currentBlockSize, -20),
ishft(ulong(total(memBlockSizes)), -20)
endfor

ptr_free,memPtrs
end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: cgimage and color tables
Next Topic: Re: Extraction phenological events

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Nov 29 08:29:59 PST 2025

Total time taken to generate the page: 1.19880 seconds