473,388 Members | 981 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 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 4913
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bob | last post by:
I have an abstract class Thing which has a static method Thing GetThing(). Class Something inherits from Thing. SomeThing supplies static info for GetThing to get stuff from the database to create...
2
by: boy | last post by:
Hi all, I have created a simple template class as follow, but i encountered memory leakage on the base.Render(writer). Have all you of encountered the same problem? using System; using...
3
by: Doug | last post by:
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...
0
by: richard sancenot | last post by:
I experience a HUGE memory leak (in fact, a handle leak) calling SetElementHtml. In fact, it's the function put_innerHTML and some other one that are responsible for that. CString sHtmlContent...
6
by: gg9h0st | last post by:
i really wander what makes static method special? in fact i can access a non static method statically using '::' class aclass { function anonstatic() { echo 'non static'; } static...
9
by: gaya3 | last post by:
Hi all, How does the static method is called without creating any instance for that class?How does this functionality works?Thanks in Advance. -Thanks & Regards, Hamsa
1
by: samdediacre | last post by:
Hi all, I have developped a very simple Windows service that references a managed .NET dll. the code within the dll contains a static class to read/write data from registry. So the OnStart()...
1
by: svatauli1983 | last post by:
Hi all, can someone write me if is normal to have business layer of static methods. Example: from page.aspx.cs calling static method in other assembly (static methods doesnt use state variables)....
1
by: rythmic | last post by:
Hi! PHP is really nifty in the way you can instantiate classes by using string variables like so: $str_class_name = 'User'; $instance = new $str_class_name(); That way you can create...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.