Objects "Eating" up memory

  • Thread starter Thread starter Zahid
  • Start date Start date
Z

Zahid

Hi,

Im writing and testing an app (written in VB.Net) on my
PocketPC which dynamically creates buttons and places
them on tabpages in a tabcontrol. The buttons are custom
created buttons. In one on the tabpages certain buttons,
if clicked, will refresh the tabpage they are contained
in by loading a new set of buttons.

On inspecting this further i have found that this is
eating away my memory. Why? If a button loads a new set
of buttons then in my code the first line i have placed
is "frm1.TabControl1.Tabpages.Clear()" which forces the
tabpage to be deleted/disposed so that new fresh tabpages
are created for the new set of buttons.

When I call the line "frm1.TabControl1.Tabpages.Clear()"
does this also delete my custom designed buttons also? Or
do they still exist - hence why the memory is being eaten
into?

All advice and help is GREATLY appreciated.
Thanks in advance.
 
Thanks,

Do you mean create a destructor for my custom buttons and
call the Dispose method from inside it?

How do i remove the buttons from the forms controls
collection? Sorry but im a lil new to VB.Net.

Thanks in advance,
Zahid.
 
Form.Controls.Remove(myButton)
myButton.Dispose()

The reason is that in NetCF there is an inaccessible directly reference to
every control in a global private static array - member of the Control
class, which prevents GC from collecting it
 
Hi,

I tried your code but the memory is still being eaten
away sadly. Is there anything else I can try?

Thanks in advance.
 
Back
Top