User Data memory does not get free on window close

bridged with qdn.public.qnx4.photon
Post Reply
Seto

User Data memory does not get free on window close

Post by Seto » Wed Nov 05, 2003 3:50 am

hi all,

I have a application in which i have created few child windows, in each
child window their are many widgets.

For each such widget i have attached USER DATA. i can see the memory
getting consumed as i go on opening windows one after another. but when i
close window on after another i can not see the memory getting free.

When we attach any USER DATA to any widget, does it not get free when we
distroy that specific widget? or when we close the window in which that
specific widget is located ?

what could be the problem in freeing the memory area consumed by USER DATA
attached earlier ?

Please Help....

Thanks in advance,

Sameer

Bill Caroselli

Re: User Data memory does not get free on window close

Post by Bill Caroselli » Wed Nov 05, 2003 2:28 pm

Seto <seto@vsnl.com> wrote:
S > hi all,

S > I have a application in which i have created few child windows, in each
S > child window their are many widgets.

S > For each such widget i have attached USER DATA. i can see the memory
S > getting consumed as i go on opening windows one after another. but when i
S > close window on after another i can not see the memory getting free.

S > When we attach any USER DATA to any widget, does it not get free when we
S > distroy that specific widget? or when we close the window in which that
S > specific widget is located ?

S > what could be the problem in freeing the memory area consumed by USER DATA
S > attached earlier ?

S > Please Help....

S > Thanks in advance,

S > Sameer

There are several issues here.

1.
Make sure that you have a good understanding of Realize/Unrealize and
Create/Destroy. Basically, Realize mean show; Unrealize means hide.
Create means to allocate and initialize memory for a widget, Destroy
mean to unallocate the memory for a widget.

I don't think that closing a window automatically destroys it. You
must do that in a callback.

2.
You may do what ever you want with USER_DATA. If you are allocating
memory and storing the pointer in USER_DATA the system has no way of
knowing that. So it would be your responsibility to free that memory
at the time that the widget is destroyed. You can use a CB_DESTROYED
for this purpose.

3.
When memory is allocated from the heap (ala malloc(), et al) and
subsequently free()ed, it is not freed back to the OS. It is only
free()ed back to your own heap. When your program terminates, all the
memory is freed back to the OS.

Post Reply

Return to “qdn.public.qnx4.photon”