Recently I came across a problem 32 bit application querying the .NET CLR Memory “Gen 1 heap size” performance counter returning no data for x64 managed processes on 64 bit windows.
I found that problem persists with all .NET CLR counters. You can see the same problem in perfmon as well. Launch 32 bit perfmon, go to C:\Windows\SysWow64\pefmon.exe and add any .NET CLR counter you will see none of the 64 bit applications are listed in ‘Instances of Selected Objects’.
Doing further research I found that it is a known problem with .NET CLR performance data provider dll. See:: http://support.microsoft.com/kb/922775
You cannot monitor 32-bit managed programs in the 64-bit version of Perfmon
One part of the problem is fixed in later version of .NET framework. Starting .NET framework 3.0 64 bit counters of .NET CLR can read 32 bit application’s performance data. On the contrary 32 bit application can still not read the .NET CLR performance counters of 64 bit managed application.
The only way to work it around is to use 64 bit version of .NET CLR counters.
If you have a 32 bit application which you are running on 64 bit windows. You would need to consider following workaround
1) Launch a 64 bit application to read .NET CLR performance data and implement IPC to get it transferred to 32 bit application.
2) Launch a 64 bit application to write .NET CLR performance data in a log file. Read the log file from 32 bit application.