473,545 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4941
Doug <Do**@discussio ns.microsoft.co m> 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.co m>
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.ToStri ng().
Doug wrote:
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:

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
1733
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 a Something. Now I have a collection Things<T>:List<T> where T:Thing. In that collection's code how can I call Thing's static method? ...
2
1318
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 System.Web.UI; public class PageBase : System.Web.UI.Page {
3
284
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 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...
0
884
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 = _T("Here is a memory leak"); BSTR bstr = m_sHtmlContent.AllocSysString(); for(int i = 0; i < 100; i++) SetElementHtml("MyDIV" , bstr);...
6
31723
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 function astatic() {
9
1841
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
2022
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() method of the service simply calls the dll to read info from registry, but the static method reading info fails to execute... the dll tested within a...
1
2783
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). Can be some problem when more requests will be calling that static method in same time? And How static methods works? That method is created (new...
1
2558
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 flows where classes that are used in the same way can use the same code even if you don't know which class will use the code beforehand.
0
7490
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7682
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7935
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5351
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5069
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.