Memory Leak calling static method

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Doug

    #1

    Memory Leak calling static method

    We are calling a static method in a class part of the project. This is C#.
    If we pass variables we see a constant growth in memory that does not seem
    to stop.
    If we do not pass variables, the memory usage does not grow.

    We understand GC is supposed to take care of releasing memory, but we
    started to go over 300,000,000 and decided this was not OK.

    Any thoughts/help is appreciated.

  • Jon Skeet [C# MVP]

    #2
    Re: Memory Leak calling static method

    Doug <Doug@discussio ns.microsoft.co m> wrote:[color=blue]
    > We are calling a static method in a class part of the project. This is C#.
    > If we pass variables we see a constant growth in memory that does not seem
    > to stop.
    > If we do not pass variables, the memory usage does not grow.
    >
    > We understand GC is supposed to take care of releasing memory, but we
    > started to go over 300,000,000 and decided this was not OK.
    >
    > Any thoughts/help is appreciated.[/color]

    Could you post a short but complete program which demonstrates the
    problem?

    See http://www.pobox.com/~skeet/csharp/complete.html for details of
    what I mean by that.

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    • Mattias Sjögren

      #3
      Re: Memory Leak calling static method

      [color=blue]
      >We are calling a static method in a class part of the project. This is C#.
      >If we pass variables we see a constant growth in memory that does not seem
      >to stop.
      >If we do not pass variables, the memory usage does not grow.[/color]

      Please show us relevant parts of your code. Or use a profiler to learn
      what type of objects are causing the increase in memory use.



      Mattias

      --
      Mattias Sjögren [MVP] mattias @ mvps.org
      http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
      Please reply only to the newsgroup.

      Comment

      • Joshua Flanagan

        #4
        Re: Memory Leak calling static method

        My initial guess would be that it has nothing to do with the empty
        static method. If there truly is a problem, it is probably in the
        implementation of aMessage.ToStri ng().


        Doug wrote:[color=blue]
        > Here are the relevant parts of the code:
        >
        > In the main program I have the following call:
        >
        >
        > TMLogging.TMLog icListeners(aMe ssage.ToString( ), 4, 0);
        >
        >
        > Note that there is no code in the method I am calling. Whether or not there
        > is code the memory increases each time I call it.
        >
        > If I comment out the call the memory does not increase.
        >
        > The Class:
        >
        > using System;
        > using System.IO;
        > using System.Diagnost ics;
        > using System.Text;
        >
        >
        > /// <summary>
        > /// Summary description for TMLogging.
        > /// </summary>
        > ///
        > namespace TMReceive
        > {
        > public class TMLogging
        > {
        > // Must determine what folder is the default for a Service?
        >
        > public TMLogging()
        > {
        > //
        > // TODO: Add constructor logic here
        > //
        > }
        > public static void TMLogicListener s(string Message, int Level, int Type)
        > {
        > }
        > }
        >
        >
        > "Doug" wrote:
        >
        >[color=green]
        >>We are calling a static method in a class part of the project. This is C#.
        >>If we pass variables we see a constant growth in memory that does not seem
        >>to stop.
        >>If we do not pass variables, the memory usage does not grow.
        >>
        >>We understand GC is supposed to take care of releasing memory, but we
        >>started to go over 300,000,000 and decided this was not OK.
        >>
        >>Any thoughts/help is appreciated.
        >>[/color][/color]

        Comment

        Working...