Memory leaks and how to solve them

  • Thread starter Thread starter Daan
  • Start date Start date
D

Daan

Users of the application I have developed report an occasional
OutOfMemoryException. This prompted me to do some research on memory
management and related issues and I have learned to use the NetCFRPM
tool in combination with perfmon.

In my application, there is a task list. When the user clicks on a
task, the details of this task are shown. Tapping 'back' takes them
back to the task list. I can see with the tools that every time the
user views details and goes back, the Managed Bytes Allocated counter
increases. Also, the count of a number of items only increases in the
'compare heap' overview in the NetCFRPM tool, in particular the
Microsoft.AGL.Forms.WnProc and the System.EventHandler and a number of
GUI components.

Now my problem is, I know these issues exist, I just can't trace them
to any particular point in my source code. Is there a better solution
then just 'code inspection' or will I have to hunt through all the
lines of code until I find the source of the problem?

Thanks for any suggestions!
Daan
 
There's no CF 2.0 tool that will directly pinpoint where the allocation was
made but not released (though RPM 3.5 also has a profiler tool that will
show this, so installing Studio 2008 beta for this tool might be useful).
It sounds like you are creating a new task list form every time but still
holding some reference to the old one (like in an event handler) so they're
stacking up (no pun intended) in the Heap.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
 
There's no CF 2.0 tool that will directly pinpoint where the allocation was
made but not released (though RPM 3.5 also has a profiler tool that will
show this, so installing Studio 2008 beta for this tool might be useful).
It sounds like you are creating a new task list form every time but still
holding some reference to the old one (like in an event handler) so they're
stacking up (no pun intended) in the Heap.

--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded Worldwww.OpenNETCF.com









- Tekst uit oorspronkelijk bericht weergeven -

Every time the 'details' view is displayed, 25 new custom controls are
created to display the details of the task. When the 'list' view is
displayed, the panel and any list that contains the 25 custom controls
are cleared. I have tried adding code that removes the event handler
from the items on the panel before clearing the panel.Controls, but
this does not solve the problem. Is there any other way (other then
event handlers) that a reference can still exist to the objects, even
though they are cleared from the panel?
 
Back
Top