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

Home » Public Forums » archive » Re. MEMORY MANAGEMENT
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: Re. MEMORY MANAGEMENT [message #8769 is a reply to message #8768] Tue, 22 April 1997 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
John Slavic writes:

> I'm presently building an extensive widget which will have to handle
> very large arrays (6,170000), and noticed that IDL is always asking for
> more memory. I tried to solve the problem with pointers, but alas... I
> also noticed that the heap keeps building up when I quit my widget
> (widget_control, event.top,/destroy) and start the widget again. For
> example, everytime I restart the widget and call "help, /memory," the
> heap, malloc, and free memory keeps on growing and growing and...., then
> the computer crashes, 8-(. So I quit and restart IDL, and the memory
> goes back down to zero.
> Does anyone have a good idea of how I can clean the heap memory within
> the widget without having to restart IDL?

This is almost certainly because you are not "cleaning up" your pointers
when your widget program crashes during development. I presume you are
storing your pointers in some kind of "info" structure in the user value of
the top-level base. I would set a clean-up procedure for that top-level
base by using the CLEANUP keyword to the XMANAGER call:

XMANAGER, 'myprogram', tlb, CLEANUP='myprogram_cleanup'

A typical cleanup routine might look like this:

PRO MYPROGRAM_CLEANUP, id
WIDGET_CONTROL, id, GET_UVALUE=info, /NO_COPY
IF N_ELEMENTS(info) NE 0 THEN BEGIN
HANDLE_FREE, info.ptr
WDELETE, info.pixmap
ENDIF
END

Unfortunately, this won't prevent memory leakage when your program
crashes with the info structure "checked out" of your top-level base.
(I presume you are using /NO_COPY keywords with that large array!)
Then you might just have to remember to type: HANDLE_FREE, info.ptr
*before* you type "RETALL" and "XMANAGER".

This is not a perfect solution, but I bet it helps.

> Since I'm writing this, I have another "simple" question. Is
there any
> way to change the black background of a plot window?

TVLCT, 255, 255, 255, !P.Background

Cheers!

David

----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
Customizable IDL Programming Courses
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
[Message index]
 
Read Message
Read Message
Previous Topic: Re: TIFF header
Next Topic: Re: Object Oriented Programming Book Recommendation

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

Current Time: Fri Oct 10 14:00:14 PDT 2025

Total time taken to generate the page: 0.00621 seconds