Results 1 to 3 of 3

Thread: C# Hunting memory leaks

  1. #1
    HEXUS.social member finlay666's Avatar
    Join Date
    Aug 2006
    Location
    Newcastle
    Posts
    8,546
    Thanks
    297
    Thanked
    894 times in 535 posts
    • finlay666's system
      • CPU:
      • 3570k
      • Memory:
      • 16gb
      • Graphics card(s):
      • 6950 2gb
      • Case:
      • Fractal R3
      • Operating System:
      • Windows 8
      • Monitor(s):
      • U2713HM and V222H
      • Internet:
      • cable

    C# Hunting memory leaks

    Does anyone know of any tools/techniques for hunting down memory leaks in C#?

    I have a relatively large mobile app now using about 5mb of RAM at runtime and I seem to only be disposing of 3-4mb of that RAM and can't find out where the rest is escaping.

    Suggestions welcome
    H3XU5 Social FAQ
    Quote Originally Posted by tiggerai View Post
    I do like a bit of hot crumpet

  2. #2
    Seething Cauldron of Hatred TheAnimus's Avatar
    Join Date
    Aug 2005
    Posts
    17,164
    Thanks
    803
    Thanked
    2,152 times in 1,408 posts

    Re: C# Hunting memory leaks

    JetBrains dotTrace is my personal favourite.

    But first places to look, when you deal with un-managed resources via p/invoke.

    classic interview question "you can only un-load appdomains, not assemblies or types" so things like the XmlSerializer that generate code on the fly can leak. As such you might as well leak only one instance, by always making them static readonly.

    Never use code in finalizers, there is only ever one finalizer thread in .Net so blocking it can create issues.
    throw new ArgumentException (String, String, Exception)

  3. #3
    HEXUS.social member finlay666's Avatar
    Join Date
    Aug 2006
    Location
    Newcastle
    Posts
    8,546
    Thanks
    297
    Thanked
    894 times in 535 posts
    • finlay666's system
      • CPU:
      • 3570k
      • Memory:
      • 16gb
      • Graphics card(s):
      • 6950 2gb
      • Case:
      • Fractal R3
      • Operating System:
      • Windows 8
      • Monitor(s):
      • U2713HM and V222H
      • Internet:
      • cable

    Re: C# Hunting memory leaks

    I have my own text writer/reader so that could be an issue, I don't have finalizers, custom cleanup methods I call in their own try/catch so I can find out if an exception is thrown but nothing is thrown.


    I'll look into the p/invoke and dotTrace though, thanks
    H3XU5 Social FAQ
    Quote Originally Posted by tiggerai View Post
    I do like a bit of hot crumpet

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Which companies are the first tier manufacturers of computer memory?
    By Kerandran in forum PC Hardware and Components
    Replies: 12
    Last Post: 21-10-2008, 08:11 PM
  2. Memory bandwidth tests... any real differences (PC4300 vs. PC7100)
    By graysky in forum PC Hardware and Components
    Replies: 0
    Last Post: 30-10-2007, 10:18 PM
  3. Abit IP35 memory config..
    By daveasp in forum PC Hardware and Components
    Replies: 8
    Last Post: 25-10-2007, 07:18 PM
  4. DDR2 Memory Failure Rate?
    By Thor in forum PC Hardware and Components
    Replies: 31
    Last Post: 18-10-2007, 09:11 PM
  5. Overclocking A64s?
    By Prodigy in forum PC Hardware and Components
    Replies: 4
    Last Post: 09-09-2004, 03:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •