none
Incorrect process IDs returned by WMI's Win32_PerfFormattedData_NETFramework_NETCLRMemory RRS feed

  • Question

  • I'm using WMI's Win32_PerfFormattedData_NETFramework_NETCLRMemory query to retrieve information about local .NET processes. It works fine for most processes, but a few processes return 0 for ProcessID (despite their real process ID is not 0).


    			_searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PerfFormattedData_NETFramework_NETCLRMemory");
    			foreach (var obj in _searcher.Get())
    			{
    				var properties = obj.Properties.Cast<PropertyData>().Select(val => string.Format("{0}={1}", val.Name, val.Value)).ToList();
    				var message = string.Join(" ", properties);
    				Console.WriteLine("{0} {1} {2}\r\n", obj["ProcessID"], obj["Name"], message);
    			}
    

    And getting:

    0 WmiCollector.vshost AllocatedBytesPersec=0 Caption= Description= FinalizationSurvivors=0 Frequency_Object= Frequency_PerfTime= Frequency_Sys100NS= Gen0heapsize=0 Gen0PromotedBytesPerSec=0 Gen1heapsize=0 Gen1PromotedBytesPerSec=0 Gen2heapsize=0 LargeObjectHeapsize=0 Name=ServiceInformationCollector.vshost NumberBytesinallHeaps=0 NumberGCHandles=170 NumberGen0Collections=0 NumberGen1Collections=0 NumberGen2Collections=0 NumberInducedGC=0 NumberofPinnedObjects=0 NumberofSinkBlocksinuse=294 NumberTotalcommittedBytes=0 NumberTotalreservedBytes=0 PercentTimeinGC=0 ProcessID=0 PromotedFinalizationMemoryfromGen0=0 PromotedMemoryfromGen0=0 PromotedMemoryfromGen1=0 Timestamp_Object= Timestamp_PerfTime=Timestamp_Sys100NS=

    Any ideas why this can be happening?


    Friday, October 16, 2015 6:26 AM

Answers

All replies

  • Hi Andrey_F,

    >>It works fine for most processes, but a few processes return 0 for ProcessID (despite their real process ID is not 0).

    Yes, I also reproduced in my local machine.

    I've checked From the wikipedia page titled: Process identifier:

    <Copied>

    There are two tasks with specially distinguished process IDs: swapper  or sched has process ID 0 and is responsible for paging, and is  actually part of the kernel rather than a normal user-mode process. 

    <End>

    In a short summary

    The process with Process ID 0 is the scheduler,

    Process ID Description:
      0   The Scheduler
      1   The init process
      2   kflushd
      3   kupdate
      4   kpiod
      5   kswapd
      6   mdrecoveryd

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Kristin Xie Monday, October 19, 2015 2:40 AM
    Monday, October 19, 2015 2:39 AM
  • > There are two tasks with specially distinguished process IDs: swapper  or sched has process ID 0

    The process I asked about (see the dump in my question) is not one of these processes.

    Monday, October 19, 2015 9:58 AM
  • Does the process making those WMI calls have proper privileges?

    As an aside, you might want to assign the _searcher.Get() results to a variable so the Get() call isn't executed each iteration of the foreach loop.

    Monday, October 19, 2015 3:42 PM
  • > Does the process making those WMI calls have proper privileges?

    The caller process is executed under Admin account with elevated rights.

    >so the Get() call isn't executed each iteration of the foreach loop.

    Are you sure it is?
    Tuesday, October 20, 2015 12:27 AM
  • > There are two tasks with specially distinguished process IDs: swapper  or sched has process ID 0

    The process I asked about (see the dump in my question) is not one of these processes.

    @Andrey_F,

    >>The process I asked about (see the dump in my question) is not one of these processes.

    Did I misunderstand you? What do you mean above?

    Here is what I do.  I've made your code a little change.

    Console.WriteLine("ProcessID={0}\n   Name={1}\n   message={2}\n", obj["ProcessID"], obj["Name"], message);


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 20, 2015 1:19 AM
  • Here is a full list of processes with zero id on my system:

    0 _Global_ AllocatedBytesPersec=0 Caption= Description= FinalizationSurvivors=67 Frequency_Object= Frequency_PerfTime= Frequency_Sys100NS= Gen0heapsize=22419280 Gen0PromotedBytesPerSec=0 Gen1heapsize=372344 Gen1PromotedBytesPerSec=0 Gen2heapsize=299480560 LargeObjectHeapsize=97389632 Name=_Global_ NumberBytesinallHeaps=397242536 NumberGCHandles=332829 NumberGen0Collections=25697 NumberGen1Collections=6637 NumberGen2Collections=1405 NumberInducedGC=1152 NumberofPinnedObjects=189 NumberofSinkBlocksinuse=28502 NumberTotalcommittedBytes=419172352 NumberTotalreservedBytes=1291714560 PercentTimeinGC=19 ProcessID=0 PromotedFinalizationMemoryfromGen0=26644 PromotedMemoryfromGen0=312696 PromotedMemoryfromGen1=883188 Timestamp_Object= Timestamp_PerfTime= Timestamp_Sys100NS=
    
    0 WmiCollector AllocatedBytesPersec=0 Caption= Description= FinalizationSurvivors=0 Frequency_Object= Frequency_PerfTime= Frequency_Sys100NS= Gen0heapsize=0 Gen0PromotedBytesPerSec=0 Gen1heapsize=0 Gen1PromotedBytesPerSec=0 Gen2heapsize=0 LargeObjectHeapsize=0 Name=ServiceInformationCollector NumberBytesinallHeaps=0 NumberGCHandles=126 NumberGen0Collections=0 NumberGen1Collections=0 NumberGen2Collections=0 NumberInducedGC=0 NumberofPinnedObjects=0 NumberofSinkBlocksinuse=10 NumberTotalcommittedBytes=0 NumberTotalreservedBytes=0 PercentTimeinGC=0 ProcessID=0 PromotedFinalizationMemoryfromGen0=0 PromotedMemoryfromGen0=0 PromotedMemoryfromGen1=0 Timestamp_Object= Timestamp_PerfTime= Timestamp_Sys100NS=
    
    0 msvsmon AllocatedBytesPersec=0 Caption= Description= FinalizationSurvivors=0 Frequency_Object= Frequency_PerfTime= Frequency_Sys100NS= Gen0heapsize=0 Gen0PromotedBytesPerSec=0 Gen1heapsize=0 Gen1PromotedBytesPerSec=0 Gen2heapsize=0 LargeObjectHeapsize=0 Name=msvsmon NumberBytesinallHeaps=0 NumberGCHandles=24 NumberGen0Collections=0 NumberGen1Collections=0 NumberGen2Collections=0 NumberInducedGC=0 NumberofPinnedObjects=0 NumberofSinkBlocksinuse=34 NumberTotalcommittedBytes=0 NumberTotalreservedBytes=0 PercentTimeinGC=0 ProcessID=0 PromotedFinalizationMemoryfromGen0=0 PromotedMemoryfromGen0=0 PromotedMemoryfromGen1=0 Timestamp_Object= Timestamp_PerfTime= Timestamp_Sys100NS=
    
    0 WmiCollector.vshost AllocatedBytesPersec=0 Caption= Description= FinalizationSurvivors=0 Frequency_Object= Frequency_PerfTime= Frequency_Sys100NS= Gen0heapsize=0 Gen0PromotedBytesPerSec=0 Gen1heapsize=0 Gen1PromotedBytesPerSec=0 Gen2heapsize=0 LargeObjectHeapsize=0 Name=ServiceInformationCollector.vshost NumberBytesinallHeaps=0 NumberGCHandles=43 NumberGen0Collections=0 NumberGen1Collections=0 NumberGen2Collections=0 NumberInducedGC=0 NumberofPinnedObjects=0 NumberofSinkBlocksinuse=7 NumberTotalcommittedBytes=0 NumberTotalreservedBytes=0 PercentTimeinGC=0 ProcessID=0 PromotedFinalizationMemoryfromGen0=0 PromotedMemoryfromGen0=0 PromotedMemoryfromGen1=0 Timestamp_Object= Timestamp_PerfTime= Timestamp_Sys100NS=
    
    0 PresentationFontCache AllocatedBytesPersec=0 Caption= Description= FinalizationSurvivors=0 Frequency_Object= Frequency_PerfTime= Frequency_Sys100NS= Gen0heapsize=0 Gen0PromotedBytesPerSec=0 Gen1heapsize=0 Gen1PromotedBytesPerSec=0 Gen2heapsize=0 LargeObjectHeapsize=0 Name=PresentationFontCache NumberBytesinallHeaps=0 NumberGCHandles=220 NumberGen0Collections=0 NumberGen1Collections=0 NumberGen2Collections=0 NumberInducedGC=0 NumberofPinnedObjects=0 NumberofSinkBlocksinuse=3 NumberTotalcommittedBytes=0 NumberTotalreservedBytes=0 PercentTimeinGC=0 ProcessID=0 PromotedFinalizationMemoryfromGen0=0 PromotedMemoryfromGen0=0 PromotedMemoryfromGen1=0 Timestamp_Object= Timestamp_PerfTime= Timestamp_Sys100NS=
    
    0 IpOverUsbSvc AllocatedBytesPersec=0 Caption= Description= FinalizationSurvivors=0 Frequency_Object= Frequency_PerfTime= Frequency_Sys100NS= Gen0heapsize=0 Gen0PromotedBytesPerSec=0 Gen1heapsize=0 Gen1PromotedBytesPerSec=0 Gen2heapsize=0 LargeObjectHeapsize=0 Name=IpOverUsbSvc NumberBytesinallHeaps=0 NumberGCHandles=35 NumberGen0Collections=0 NumberGen1Collections=0 NumberGen2Collections=0 NumberInducedGC=0 NumberofPinnedObjects=0 NumberofSinkBlocksinuse=3 NumberTotalcommittedBytes=0 NumberTotalreservedBytes=0 PercentTimeinGC=0 ProcessID=0 PromotedFinalizationMemoryfromGen0=0 PromotedMemoryfromGen0=0 PromotedMemoryfromGen1=0 Timestamp_Object= Timestamp_PerfTime= Timestamp_Sys100NS=
    
    


    The only "special" entry here is _Global_; all other processes are just normal processes.

    msvsmon is running under my account, so it's not an access problem too.

    Tuesday, October 20, 2015 1:39 AM
  • Hi Andrey_F,

    Can you see my shared gif files? If not,

    https://onedrive.live.com/?id=E721AFC9DF7BAB19%21105&cid=E721AFC9DF7BAB19&group=0

    Please try to download the second picture from above link on your local site and check again.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 20, 2015 10:01 AM
  • Can you see my shared gif files?

    Yes, I see this gif file. However, I don't see any answer to my question there.

    Tuesday, October 20, 2015 12:18 PM
  • Hi Andrey_F,

    To further help you about this issue, I am trying to invoke someone experienced to help look into this thread, this may take some time and as soon as we get any result, we will post back.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 27, 2015 8:51 AM
  • I've found out that this problem is happening with all .NET processes until they run the first garbage collection; they show the correct process ID after the garbage collection is executed.

    Looks like a bug, doesn't it?

    Friday, October 30, 2015 3:11 AM
  • I've found out that this problem is happening with all .NET processes until they run the first garbage collection; they show the correct process ID after the garbage collection is executed.

    Looks like a bug, doesn't it?

    Yes,  I agree with you. Please submit a bug to Connect: https://connect.microsoft.com/

    By the way, please also post the submitted link here. Thanks。

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, October 30, 2015 4:19 AM
    • Proposed as answer by Kristin Xie Thursday, November 5, 2015 3:08 AM
    • Edited by Andrey_F Monday, November 9, 2015 2:58 AM
    • Marked as answer by Andrey_F Monday, November 9, 2015 2:58 AM
    Friday, October 30, 2015 9:13 AM
  • Hi Andrey,

    Thanks for sharing the link here, I will help you vote it.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, November 5, 2015 3:08 AM