Re. MEMORY MANAGEMENT [message #8768] |
Tue, 22 April 1997 00:00 |
john Slavich
Messages: 5 Registered: March 1997
|
Junior Member |
|
|
Hello newsgroup,
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?
Since I'm writing this, I have another "simple" question. Is there any
way to change the black background of a plot window?
Thanks for help, JOhn
|
|
|
Re: Re. MEMORY MANAGEMENT [message #8769 is a reply to message #8768] |
Tue, 22 April 1997 00:00  |
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
|
|
|