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

Home » Public Forums » archive » Re: Deallocate Memory for a Structure
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: Deallocate Memory for a Structure [message #45804] Sat, 15 October 2005 04:07
Armando Riccardi is currently offline  Armando Riccardi
Messages: 1
Registered: October 2005
Junior Member
andrew.cool@dsto.defence.gov.au wrote:
> Robert Moss wrote:
>
>> Reimar Bauer wrote:
>>
>>> a=create_Struct('test',1)
>>> a=0
>>>
>>> or
>>>
>>> dummy=temporary(a)
>>>
>>
>> dummy = temporary( a ) does not free any memory. It simply renames the
>> variable that contains the structure. Setting a to zero certainly does
>> work.
>>
>>
>> --
>> Robert Moss, PhD
>
>
> But, if you place dummy=temporary(a) in a procedure, it does free up
> memory - see DF's tip at
> http://www.dfanning.com/tips/variable_undefine.html
>
> Andrew
>

The correct command is:
dummy=size(temporary(a))
that deallocate memory.

Armando
Re: Deallocate Memory for a Structure [message #45805 is a reply to message #45804] Sat, 15 October 2005 00:15 Go to previous message
Andrew Cool is currently offline  Andrew Cool
Messages: 219
Registered: January 1996
Senior Member
Robert Moss wrote:
> Reimar Bauer wrote:
>>
>> a=create_Struct('test',1)
>> a=0
>>
>> or
>>
>> dummy=temporary(a)
>>
>
> dummy = temporary( a ) does not free any memory. It simply renames the
> variable that contains the structure. Setting a to zero certainly does
> work.
>
>
> --
> Robert Moss, PhD

But, if you place dummy=temporary(a) in a procedure, it does free up
memory - see DF's tip at
http://www.dfanning.com/tips/variable_undefine.html

Andrew
Re: Deallocate Memory for a Structure [message #45806 is a reply to message #45805] Fri, 14 October 2005 21:46 Go to previous message
Robert Moss is currently offline  Robert Moss
Messages: 74
Registered: February 1996
Member
Reimar Bauer wrote:
>
> a=create_Struct('test',1)
> a=0
>
> or
>
> dummy=temporary(a)
>

dummy = temporary( a ) does not free any memory. It simply renames the
variable that contains the structure. Setting a to zero certainly does
work.


--
Robert Moss, PhD
Re: Deallocate Memory for a Structure [message #45811 is a reply to message #45806] Fri, 14 October 2005 00:34 Go to previous message
peter.albert@gmx.de is currently offline  peter.albert@gmx.de
Messages: 108
Registered: July 2005
Senior Member
Or, if you are using a structure of pointers:

for i = 0, n_tags(struc) -1 do $
if ptr_valid(struc.(i)) then ptr_free, struc.(i)

or, if you just want to get rid of all pointers:

ptr_free, ptr_valid(/cast)

Regards,

Peter
Re: Deallocate Memory for a Structure [message #45812 is a reply to message #45811] Fri, 14 October 2005 00:06 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Archais wrote:
> I am reading data files in IDL into a structure that was defined by
> ascii_template. Once the data is loaded, the structure is fairly
> large. The data files are organized in days and I have the data
> loading routine in a loop over the number of days in a year so that the
> same structure gets written over with a new day's data for each
> iteration. The program starts out fine, loading the data fairly
> quickly, but the program begins slowing down gradually. I'm pretty
> sure its a memory issue, but I can't seem to find any routine that will
> deallocate the memory used by the structure. Is there any such
> routine, and if so what is it?
>
> Thanks
> Archais
>


a=create_Struct('test',1)
a=0

or

dummy=temporary(a)


If you use pointers


a=ptr_new(create_Struct('test',1))

ptr_free,a



Did you have profiled your routine?

cheers

Reimar


--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
============================================================ =======
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: List of Points --> ROI via IDLVECTOR data type for iimage itool
Next Topic: Loading ASCII data into an array

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

Current Time: Wed Oct 08 13:48:44 PDT 2025

Total time taken to generate the page: 0.00663 seconds