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

Home » Public Forums » archive » Re: memory leaks with xloadct?
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: memory leaks with xloadct? [message #33480] Wed, 08 January 2003 11:55 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Rob Dimeo (robert.dimeo@nist.gov) writes:

> I have been using XLOADCT in a widget program and I ran into a problem
> with leaking memory. When I run XLOADCT in a widget program where the
> top-level base of the widget program is the group leader for XLOADCT,
> quitting the widget program while XLOADCT is running SHOULD be
> seamless. However I consistently have leaking memory with the
> following in the output log:
>
> <PtrHeapVar391904>
> STRUCT = -> WIDGET_BUTTON Array[1]

The problem is that XLOADCT cleans up after itself if
you hit the DONE button, but not otherwise. This is
*exactly* why widget programs need CLEANUP routines that
get called when programs die! :-)

This problem is even more pernicious, since the pointer
that needs to get cleaned up is in a Common block, so you
can't even free it up with HEAP_GC!

Here is a cleanup routine for XLOADCT:

;*********************************************************
PRO xloadct_cleanup, id
COMMON colors, r_orig, g_orig, b_orig, r_curr, g_curr, b_curr
COMMON xloadct_com, r0, g0, b0, tfun, state, filename, cps, psave, pnt,
$
top, bot, silent, chop, lock, g_lbl, vbot, vtop, g_slider, $
gamma, color, use_values, ncolors, cbot, siz, w_height, show_win, $
updt_callback, p_updt_cb_data
if PTR_VALID(p_updt_cb_data) then PTR_FREE, p_updt_cb_data
END
;*********************************************************


Assign it like this:

XManager, "xloadct", base, NO_BLOCK=(NOT(FLOAT(block))), $
Cleanup='xloadct_cleanup'


That should do it. :-)

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: memory leaks with xloadct? [message #33553 is a reply to message #33480] Wed, 08 January 2003 15:06 Go to previous message
robert.dimeo is currently offline  robert.dimeo
Messages: 42
Registered: November 2001
Member
David, thanks for the response. This is exactly what I needed!

David Fanning <david@dfanning.com> wrote in message news:<MPG.1886302a1f6b8dbc989a9a@news.frii.com>...

> The problem is that XLOADCT cleans up after itself if
> you hit the DONE button, but not otherwise. This is
> *exactly* why widget programs need CLEANUP routines that
> get called when programs die! :-)
>
> This problem is even more pernicious, since the pointer
> that needs to get cleaned up is in a Common block, so you
> can't even free it up with HEAP_GC!
>
> Here is a cleanup routine for XLOADCT:
>
> ;*********************************************************
> PRO xloadct_cleanup, id
> COMMON colors, r_orig, g_orig, b_orig, r_curr, g_curr, b_curr
> COMMON xloadct_com, r0, g0, b0, tfun, state, filename, cps, psave, pnt,
> $
> top, bot, silent, chop, lock, g_lbl, vbot, vtop, g_slider, $
> gamma, color, use_values, ncolors, cbot, siz, w_height, show_win, $
> updt_callback, p_updt_cb_data
> if PTR_VALID(p_updt_cb_data) then PTR_FREE, p_updt_cb_data
> END
> ;*********************************************************
>
>
> Assign it like this:
>
> XManager, "xloadct", base, NO_BLOCK=(NOT(FLOAT(block))), $
> Cleanup='xloadct_cleanup'
>
>
> That should do it. :-)
>
> Cheers,
>
> David
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: map_set coastline data
Next Topic: MRI, ROI and displaying as a meshed object

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

Current Time: Wed Oct 08 19:12:18 PDT 2025

Total time taken to generate the page: 0.00548 seconds