SharedPerformanceCounter.CreateInstance exception

M

Muntz

We have written a SOAP Extension assembly that writes timings and method
counts to Performance Counter instances every time a Web Method is invoked.
This has been working stably for some years.

Recently one one server or another we have noticed some exceptions coming
out of this assembly:

System.InvalidOperationException: Custom counters file view is out of memory.
at System.Diagnostics.SharedPerformanceCounter.CreateInstance(Int32
counterNameHashCode, String counterName, Int32 instanceNameHashCode, String
instanceName)
at System.Diagnostics.SharedPerformanceCounter.GetCounter(String
categoryName, String counterName, String instanceName)
at System.Diagnostics.SharedPerformanceCounter..ctor(String
categoryName, String counterName, String instanceName)
at System.Diagnostics.PerformanceCounter.Initialize()
at System.Diagnostics.PerformanceCounter..ctor(String categoryName,
String counterName, String instanceName, Boolean readOnly)

What is the underlying cause of this exception? Can action be taken in
advance to prevent this exception occurring again?

We are MSDN Universal Subscribers. ([email protected])
 
S

Steven Cheng [MSFT]

Hi Muntz,

Regarding on the performance counter "Custom counters file view is out of
memory" error, I've performed some research. It seems this error is likely
to occur on some system which has many .NET managed performance counter
instances created or running. Because the .NET performance counter use some
file mapping share which has a default size limitation and if the limit has
been exceed, such error is raised.

#<performanceCounters> Element
http://msdn.microsoft.com/en-us/library/ms229387.aspx

Limits of sizes allowed:
Default = 524288
Max = 33554432
Min = 32768

You can set a new value in your machine.config file (similar to this):

======
<configuration>
<system.diagnostics>
<performanceCounters filemappingsize="600000" />
</system.diagnostics>
</configuration>
=================


Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
 
M

Muntz

Thanks very much for the prompt response SC.

Any ideas where this file is located? Do you know if it's possible to find
what is actually being held in this file?
 
M

Muntz

Thanks very much for the prompt response SC.

Any ideas where this file is located, to verify how large it is currently?
 
S

Steven Cheng [MSFT]

Hi Muntz,

Thanks for your reply.

As for the file the .NET performance counter uses, it is not a physical
file, but a memory mapping file. Also, the actual file info is controlled
by the .NET framework runtime which is out of our control. So far the
settings mentioned in the reference is the suggested place to configure the
file size limitation.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
From: =?Utf-8?B?TXVudHo=?= <[email protected]>
References: <[email protected]>
Subject: RE: SharedPerformanceCounter.CreateInstance exception
Date: Wed, 30 Apr 2008 00:25:00 -0700
 
S

Steven Cheng [MSFT]

Hi Muntz,

Does changing the filemappingsize helps on this or do you have any further
questions? If so, welcome to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
From: (e-mail address removed) (Steven Cheng [MSFT])
Organization: Microsoft
Date: Thu, 01 May 2008 02:49:29 GMT
Subject: RE: SharedPerformanceCounter.CreateInstance exception
 
M

Muntz

I've passed the suggested fix on to our operations staff. I'll report back
when this is applied.

In the meantime, I've noticed a new exception:

Cannot continue the current operation, the performance counters memory
mapping has been corrupted.
at System.Diagnostics.SharedPerformanceCounter.ResolveOffset(Int32
offset, Int32 sizeToRead)
at
System.Diagnostics.SharedPerformanceCounter.CalculateAndAllocateMemory(Int32
totalSize, Int32& alignmentAdjustment)
at
System.Diagnostics.SharedPerformanceCounter.CreateInstance(CategoryEntry*
categoryPointer, Int32 instanceNameHashCode, String instanceName,
PerformanceCounterInstanceLifetime lifetime)
at System.Diagnostics.SharedPerformanceCounter.GetCounter(String
counterName, String instanceName, Boolean enableReuse,
PerformanceCounterInstanceLifetime lifetime)
at System.Diagnostics.SharedPerformanceCounter..ctor(String catName,
String counterName, String instanceName, PerformanceCounterInstanceLifetime
lifetime)

Any ideas?

Steven Cheng said:
Hi Muntz,

Does changing the filemappingsize helps on this or do you have any further
questions? If so, welcome to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
From: (e-mail address removed) (Steven Cheng [MSFT])
Organization: Microsoft
Date: Thu, 01 May 2008 02:49:29 GMT
Subject: RE: SharedPerformanceCounter.CreateInstance exception
Hi Muntz,

Thanks for your reply.

As for the file the .NET performance counter uses, it is not a physical
file, but a memory mapping file. Also, the actual file info is controlled
by the .NET framework runtime which is out of our control. So far the
settings mentioned in the reference is the suggested place to configure the
file size limitation.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#noti f
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Steven Cheng [MSFT]

Thanks for your followup Muntz,

Regarding on the new error you mentioned below:

============
Cannot continue the current operation, the performance counters memory
mapping has been corrupted.
==========

I've also performed some research on this. So far what I've found is that
this error is possibely raised when you first call .NET performance
counters classes in .net framework 1.1(or maybe other higher version) and
then use .NET 1.0 classes to call the performance counters. Therefore, I'm
wondering whether there are multiple applications with different versions
that all use .NET performance counters classes?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
From: =?Utf-8?B?TXVudHo=?= <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
 
M

Muntz

We were just testing a new version of the service, which uses .NET 2.0,
against the previous version which uses .NET 1.1

Don't think there is anything accessing counters using .NET 1.0 but it's
hard to be sure.
 
S

Steven Cheng [MSFT]

Thanks for your reply Muntz,

So if there are multiple version of .net framework running on it, and some
of them use performance countes API, it does be possible that the problem
is caused by this. I think it will be helpful if you can try isolating the
problem to some certain applications(such as turn off most other
applications that will use performance counters).

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
From: =?Utf-8?B?TXVudHo=?= <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
<14mS#[email protected]>
<[email protected]>
Subject: RE: SharedPerformanceCounter.CreateInstance exception
Date: Wed, 7 May 2008 00:51:02 -0700
 
M

Muntz

Thanks for your response SC, but isn't this a pretty major flaw? Not being
able to access .NET Performance Counters via diff. versions of .NET on the
same machine?

Is there another Performance Counter API I can use to write our instance
counters?
 
S

Steven Cheng [MSFT]

Thanks for your reply Muntz,

I think the PerformanceCounters class should be the preferreed means to
access windows performance counters. The problem you encounter is possibly
due to some environment specific settings.

So currently, about the two errors you mentioned

1) the "Custom counters file view is out of memory"

2) "the performance counters memory mapping has been corrupted."

does the first problem got resolved after you apply the filemappingsize
configuration? Or is the second error the main problem you need to address
now? For the second one, it would be hard to troubleshoot from appearance,
I may try finding some futher resource to continue help you, you can send
me an email to "stcheng" +"@" + "Microsoft.com" so that I can ask you for
further information offline. Or if you feel it an urgent issue, you can
also consider contacting CSS:

Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
 
S

Steven Cheng [MSFT]

Hi Muntz,

Have you got any further progress on this? Or have you considered contact
CSS for profesional incident based support if this is really an important
and urgent issue?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

--------------------
Content-Transfer-Encoding: 7bit
From: (e-mail address removed) (Steven Cheng [MSFT])
Organization: Microsoft
Date: Fri, 09 May 2008 03:55:53 GMT
Subject: RE: SharedPerformanceCounter.CreateInstance exception
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top