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

Home » Public Forums » archive » Re: array operations and memory consumption
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: array operations and memory consumption [message #57943 is a reply to message #57942] Fri, 04 January 2008 15:16 Go to previous messageGo to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On Jan 4, 3:19 pm, dktr....@gmail.com wrote:
> Hi all,
>
> Apologies in advance if this is old hat ... I've got a question
> regarding IDL's memory usage that can be boiled down in the following
> example:
>
> IDL> a = BINDGEN(100,100,100)
> IDL> baseMem = (MEMORY())[0]
> IDL> a = a + 1
> IDL> PRINT, (MEMORY())[3] - baseMem
>      2000049
>
> I've tried modifying "a = a + 1" with various combinations of pointers
> and the TEMPORARY function, but can't reduce this temporary elevated
> memory consumption.  Compare the above with a call to CONGRID:
>
> IDL> a = BINDGEN(100,100,100)
> IDL> baseMem = (MEMORY())[0]
> IDL> a = CONGRID(a, 100, 100, 100)
> IDL> PRINT, (MEMORY())[3] - baseMem
>      1003941
>
> I'm working with some very large image arrays and trying to do some
> "in place" manipulations.  While I can slink by with the temporary
> memory usage of the latter CONGRID-type operations, addition (or
> multiplication) of an array by a scalar breaks the bank.
>
> Any tips or directions to a helpful tutorial on IDL's memory policies
> would be greatly appreciated.  Thanks!

Be careful with type conversion here! In particular, 1 is a short
integer (or long integer depending on if compile_opt defint32 is
used), so a = a + 1 here converts a to type int. Consider the
following:

IDL> a = bindgen(100, 100, 100)
IDL> orig_mem = memory(/current)
IDL> a = a + 1
IDL> print, memory(/highwater) - orig_mem
2000082

IDL> a = bindgen(100, 100, 100)
IDL> orig_mem = memory(/current)
IDL> a = a + 1B
IDL> print, memory(/highwater) - orig_mem
1000096

IDL> a = bindgen(100, 100, 100)
IDL> orig_mem = memory(/current)
IDL> a = temporary(a) + 1B
IDL> print, memory(/highwater) - orig_mem
91
IDL>
IDL> a = bindgen(100, 100, 100)
IDL> orig_mem = memory(/current)
IDL> a += 1B
IDL> print, memory(/highwater) - orig_mem
91

IDL>
IDL> a = bindgen(100, 100, 100)
IDL> orig_mem = memory(/current)
IDL> a++
IDL> print, memory(/highwater) - orig_mem
91

Mike
--
www.michaelgalloy.com
Tech-X Corporation
Software Developer II
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: array operations and memory consumption
Next Topic: Re: read_ascii for many rows / possible to create automatic names for variables

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

Current Time: Fri Oct 10 21:45:32 PDT 2025

Total time taken to generate the page: 0.24135 seconds