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

Home » Public Forums » archive » 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
Memory Leak [message #67393] Mon, 27 July 2009 15:05
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
Today's quiz is to write a short program to make IDL leak memory
without using any pointer variables or external calls.

In the program test.pro below, I read a data file containing 0b values
into a structure with a length one blank string tag. After each
call to test.pro I print the fourth element of the memory() function,
which is supposed to give the "maximum amount of dynamic memory used
since the last time the MEMORY function was called."

IDL> print,!version
{ x86 linux unix linux 7.0 Oct 25 2007 32 64}

IDL> print,(memory())(3)
778166
IDL> test1 & print,(memory())(3)
3673008
IDL> test & print,(memory())(3)
4273023
IDL> test & print,(memory())(3)
4873023

As one can see, the highwater mark for memory usage keeps increasing,
even though no variables are being added to the main level.
Evidently, memory is leaking during the conversion from 0b to a length
one blank string (which gets converted to an empty string).

(No, I am not a masochist doing this for fun -- this memory leak is
causing problems with an IDL FITS reader (mrdfits.pro) that I am
trying to maintain....)

Cheers, --Wayne


pro test
a = {a1:3b,a2:0b,a3:4b}
a = replicate(a,100000)

openw,lun,'test.dat',/get_lun
writeu,lun,a
close,lun
openr,lun,'test.dat'
out = {a1:0b,a2:' ',a3:0b}
out = replicate(out,100000)
readu,lun,out
free_lun,lun
return
end
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: adding lines of an image together
Next Topic: Re: idl -quiet command-line option doesn't work in cron

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

Current Time: Sun Oct 12 09:40:56 PDT 2025

Total time taken to generate the page: 0.64189 seconds