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

Home » Public Forums » archive » HDF files and memory leak
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
HDF files and memory leak [message #26189] Fri, 10 August 2001 04:08
Jacques is currently offline  Jacques
Messages: 5
Registered: September 1994
Junior Member
Hi all

I am trying to find out how to stop a memory leak when reading HDF files.

Here is a chunk of the code where I restore a template, and free up the
memory that it uses, and all is fine.
------------------------------------------------------------ ------
IDL Version 5.4 (linux x86). (c) 2000, Research Systems, Inc.

IDL> help, /heap
Heap Variables:
# Pointer: 0
# Object : 0
IDL> file = 'hdfaa.000'
IDL> restore, 'energy.template'
IDL> help, /heap
Heap Variables:
# Pointer: 55
# Object : 0

<PtrHeapVar1> STRUCT = -> <Anonymous> Array[1]
<PtrHeapVar2> LONG = 63

....

IDL> ptr_free, template.sd.sds.attributes
IDL> ptr_free, template.sd.sds.dims
IDL> ptr_free, template.sd.sds.dim_info
IDL> help, /heap
Heap Variables:
# Pointer: 0
# Object : 0
IDL>

------------------------------------------------------------ ------

However, when I actually read data from an HDF file...
------------------------------------------------------------ ------
IDL Version 5.4 (linux x86). (c) 2000, Research Systems, Inc.

IDL> help, /heap
Heap Variables:
# Pointer: 0
# Object : 0
IDL> file = 'hdfaa.000'
IDL> restore, 'energy.template'
IDL> help, /heap
Heap Variables:
# Pointer: 55
# Object : 0

<PtrHeapVar1> STRUCT = -> <Anonymous> Array[1]
<PtrHeapVar2> LONG = 63

...

IDL> temp = hdf_read(file, template=template)
% Restored file: HDF_READ.
% Restored file: HDF_MAP.
% Compiled module: REVERSE.
% Loaded DLM: HDF.
IDL> help, /heap
Heap Variables:
# Pointer: 165
# Object : 0

<PtrHeapVar1> STRUCT = -> <Anonymous> Array[1]
<PtrHeapVar2> LONG = 63

...

IDL> ptr_free, template.sd.sds.attributes
IDL> ptr_free, template.sd.sds.dims
IDL> ptr_free, template.sd.sds.dim_info
IDL> help, /heap
Heap Variables:
# Pointer: 110
# Object : 0

<PtrHeapVar56> STRUCT = -> <Anonymous> Array[1]
<PtrHeapVar57> LONG = 63

...

IDL> help, temp, /structure
** Structure <81ec2fc>, 4 tags, length=1000212, refs=1:
FILENAME STRING 'hdfaa.000'
VERSION STRING '1.1'
DATE STRING 'Fri Jul 27 09:42:22 2001'
_HDFAA_SD_19
FLOAT = Array[63, 63, 63]
------------------------------------------------------------ ------
So hdf_read takes up a chunk of the heap, and there are no pointers in
the variable "temp".

The HDF_BROWSER online help states:
"The user is required to clean up the heap variable references when done
with them."

So I try to run
IDL> heap_gc
IDL> help, /heap
Heap Variables:
# Pointer: 0
# Object : 0

So that seems fine, but the problem is that the memory is not freed up
and after a couple of hours (and reading hundreds of HDF files) the
memory usage (as reported by top) is up to 220MB. Nothing can free up
the memory (I've tried heap_gc and .full_reset_session).

Can anyone tell me what I need to do to free up this memory?

Thanks,
Jacques
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: histogram question
Next Topic: Re: bug in IDL's hanning() window-generating function

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

Current Time: Wed Oct 08 14:55:52 PDT 2025

Total time taken to generate the page: 0.00481 seconds