Hi all,
I have a user control with several properties and events. This user control is filled with information of one entry in an SQL database.
The problem is listed at the bottom.
First, here is some information.
-- Not sure if relevant but have a suspicion --
some Variables in the control are declared as WithEvents. Those variables are of a class type that
I made in order to get around some circular reference issues. Essentially, it allows my control
to raise an event to the main application, informing it of what needs to be done. The application, having received the event and having references to all projects, can then perform whatever action is required by the control.
How this works..
Here is my class for allowing application to monitor the needs of all existing user controls.
Class ControlEvents
Public Shared Event ViewUser(Sender as MyControl)
Sub View(Sender as MyControl)
RaiseEvent ViewUser(Sender)
End Sub
end Class
Here is the user control with a sub for viewing a user
Class MyControl
Private WithEvents Subcription_ControlEvents As New ControlEvents
Sub ViewUser()
Subcription_ControlEvents.View(Me)
End Sub
End Class
And finally, the applications Module watching for Control events and responding to them
Module UserControl_EventMonitor
Private WithEvents Subcription_ControlEvents As New ControlEvents
Private Sub MyControlClass_ViewUser(Sender as MyControl) Handles Subcription_ControlEvents.View
End Sub
End Module
----------------------------------------------------------------------
Like I said, not sue if that's relevant to my problem.
Problem:
This MyControl is used in a flow layout panel. Every time a search is run, the flow layout panel is looped through, disposing of all controls. the an sql query, then fill the FLPanel with new Controls.
!! and every time this happens the memory usage in Task Manager bumps up by 0.07 mb.
I have even tried calling the, warned against, GC.Collect() but no luck in freeing the ram.
If the search is repeated then the behavior continues until finally the out of memory exception is raised.
Anybody know whats going on here? I don't
Please help!
--------------- Update ------------------------------------------------------------
So it turns out that my Memory consumption comes from the #of sink blocks in use. From what I've read, these are weak references that are associated with a managed object. So why would calling garbage collector have no effect?