Memory leak [Updated]

    Date: 05/22/06 (C Sharp)    Keywords: no keywords

    This might be a FAQ, but I couldn't find any help elsewhere.

    In my current project, I wrote a PageControl class for navigation (we use the MVC pattern). It instantiates the new controller, gets its view and puts it on the form. The controller itself registers at some of the events of the data model, so if the data in the model changes, the controller can perform appropriate steps if necessary. If you leave a page, the controller and its view get dropped. If you go back, the controller and its view get instantiated again (due to some requirements in the project).

    My problem is, that there is a memory leak. On the start page, there are some checkboxes, where a message box pops up, if you uncheck it. If you go back to the start page, the message box popped up twice. So I added an instance member of type DateTime, that gets the date and time of the instantiation. So I found out, that this messagebox gets shown by 2 different instances. (Going forth and back again adds another instance, so you get 3 message boxes.) But I can't find out who still keeps a reference to the old instances.

    Is there a way to find out who references an object? Or is there a reference counter?

    TIA

    Update
    I found the leak. The events, where the objects registered, keep the objects on the heap.

    Source: http://community.livejournal.com/csharp/62228.html

« Enumeration conversion || zmlc 1.0 »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home