C# USER Objects Leak (10,000 Limit)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ashurack
    New Member
    • Jan 2008
    • 10

    C# USER Objects Leak (10,000 Limit)

    I'm working on an application that eventually crashes when the "USER Objects" reaches 10,000. I've gone through all the code and replaced:

    Code:
    object = null;
    with
    Code:
    if(object != null)
        object.dispose();
    
    object = null;
    Is there a way to track the objects that aren't being disposed within a class?

    Is there a way to loop through all objects within a class and dispose of all IDisposable objects?

    Thanks,
    Alan
  • PRR
    Recognized Expert Contributor
    • Dec 2007
    • 750

    #2
    Setting a object to null does not help...
    Code:
    object = null;
    You could occasionally call
    Code:
     System.GC.Collect(0, GCCollectionMode.Forced);
                    System.GC.WaitForPendingFinalizers();
                    System.GC.Collect(0, GCCollectionMode.Forced);
    assuming your objects are in generation 0...
    Look into implementing IDisposable, MSDN

    Comment

    • ashurack
      New Member
      • Jan 2008
      • 10

      #3
      Thanks,

      My problem turned out to be buttons being added to an ArrayList and never being disposed of. It's kiosk based survey software that I didn't write, lots of code to dig through.

      Comment

      Working...