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

Home » Public Forums » archive » Re: Getting memory overflow on array concat; why?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Getting memory overflow on array concat; why? [message #3423] Wed, 25 January 1995 06:54
ryba is currently offline  ryba
Messages: 33
Registered: October 1992
Member
In article <3g3oem$r43@umd5.umd.edu>, bleau@umdsp.umd.edu writes:
|> Here's the relevant code fragment, which is within a loop:
|> READF, 1, temp
|> IF first THEN BEGIN
|> data = temp
|> first = ''
|> ENDIF ELSE BEGIN
|> data = [data,temp]
|> ENDELSE

Larry (and others),

A few IDL tips....

1) Use the TEMPORARY() function whenever possible when handling large
arrays. Read the docs for the details, but the line:

data = [temporary(data),temp]

in place of what you have will halve your memory usage.

2) To reduce fragmentation, allocate in blocks...using code like:

data = fltarr(50, npar)
cursize = 50L ; Note use of longs here....
npts = 0L
while not eof(1) then begin
readf, 1, temp
data(npts, *) = temp
npts = npts + 1
if npts eq cursize then begin
data = [temporary(data), fltarr(50, npar)]
cursize = cursize + 50
endif
endwhile

data = (temporary(data))(0:npts, *)

3) You may wish to use a more general-purpose reader routine, like
DDREAD written by Fred Knight. I believe it's now in the meteo
archive; if not, mail me and I'll post it. It will read any tabular
file, skipping over comment lines, etc. with optional arguments
specifying rows and columns to pick out...I use it constantly.

--
Dr. Marty Ryba | Generation X:
MIT Lincoln Laboratory | Too young to be cynical,
ryba@ll.mit.edu | too old to be optimistic.
Of course nothing I say here is official policy, and Laboratory affiliation is
for identification purposes only, blah, blah, blah....
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: "TRUE" map projections
Next Topic: Help with Default graphics font

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

Current Time: Wed Oct 08 15:12:02 PDT 2025

Total time taken to generate the page: 0.00591 seconds