none
Major memory usage issue with PerformanceCounter RRS feed

  • Question

  • Hi-

     

    I am using a single performance counter in my application, which is created as:

     counter = new PerformanceCounter(category, counterName, instanceName);

    The counter I have setup is for the Large object heap.  I was printing it out in my console application, which calls counter.NextSample() every second, when I noticed the LOH rising by about 1mb per 1-2 seconds.  It just keeps growing and growing.  If I comment out the counter.NextSample() line, no issues with LOH.  I had not idea this happened and wasnt expecting it at all.

    I have a feeling I setting the counter up wrongly, but I dont know how:

    I first do:

    new PerformanceCounter(".NET CLR Memory", "Large Object Heap size", instanceName)

    Then every second I do:


            public void Update()
            {
                CounterSample nextSample = counter.NextSample();
                CounterSample currentSample = previous;
                double newValue = CounterSample.Calculate(currentSample, nextSample);
                previous = nextSample;

                if (Observers != null) Observers(newValue);
            }

    But its the first line that seems to be creating the data load issue on the LOH.  I was hoping to build up a whole bunch of counters for the application I am writing - with this type of memory load, they are unusable. 

    Am I doing something wrong?

    Thanks!

    mf!

     

     

    Thursday, April 22, 2010 1:29 AM

Answers