471,349 Members | 1,173 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,349 software developers and data experts.

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.

Jul 21 '05 #1
3 4668
Doug <Do**@discussions.microsoft.com> wrote:
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.


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 - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2
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.


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.
Jul 21 '05 #3
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.ToString().
Doug wrote:
Here are the relevant parts of the code:

In the main program I have the following call:
TMLogging.TMLogicListeners(aMessage.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.Diagnostics;
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 TMLogicListeners(string Message, int Level, int Type)
{
}
}
"Doug" wrote:

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.

Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Bob | last post: by
2 posts views Thread by boy | last post: by
3 posts views Thread by Doug | last post: by
reply views Thread by richard sancenot | last post: by
6 posts views Thread by gg9h0st | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.