none
FInd Process “unused memory size” with in “private bytes” using c# RRS feed

  • Question

  • As I understand Process "PrivateMemorySize64" (process.PrivateMemorySize64) contains unused memory allocated by CLR. Is there a way, I can program and find the amount of unused memory in private bytes using C#? I am selecting the process from another process and listing memory size. but since private byte also contains the "unused memory" allocated by clr, it is getting difficult for me to find the actual memory consumed by process.


    Arun Kumar Sabat

    • Moved by Kristin Xie Tuesday, March 10, 2015 5:55 AM move to better forum
    Monday, March 9, 2015 6:36 AM

Answers

  • "As I understand Process "PrivateMemorySize64" (process.PrivateMemorySize64) contains unused memory allocated by CLR."

    Yes but that's not specific to CLR, this is true about all practical memory allocators.

    "Is there a way, I can program and find the amount of unused memory in private bytes using C#?"

    Not with the Process class and not easily. There are CLR GC performance counters that can provide more information about memory usage but they're strictly about the GC heap. The CLR also allocates memory that's not part of the GC heap and it will be quite difficult or impossible to put every bit of information together to obtain what you want.

    "I am selecting the process from another process and listing memory size. but since private byte also contains the "unused memory" allocated by clr, it is getting difficult for me to find the actual memory consumed by process."

    The actual memory consumed by a process is really PrivateMemorySize64. As far as the OS is concerned that is committed memory and it's irrelevant that some of that committed memory isn't actually used by the process.

    Wednesday, March 11, 2015 10:43 AM
    Moderator
  • Hello Arun,

    >>As I understand Process "PrivateMemorySize64" (process.PrivateMemorySize64) contains unused memory allocated by CLR

    From my understanding about CLR, before it allocates memory, it should first calculate all its needed memory bytes, from this, I think all memory allocated should be used and from its description for the PrivateMemorySize64, its value returned by this property represents the current size of memory used by the process, my opinion is that this property should already show the actual memory in private bytes.

    If I do not understand correctly, please feel free to let me know.

    Regards.


    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, March 10, 2015 7:25 AM
    Moderator

All replies

  • Hi Arun Kumar Sabat,

    Based on your description, your case related to CLR forum. Now I will move your thread to that forum for better support.

    Best regadrs,

    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, March 10, 2015 5:55 AM
  • Hello Arun,

    >>As I understand Process "PrivateMemorySize64" (process.PrivateMemorySize64) contains unused memory allocated by CLR

    From my understanding about CLR, before it allocates memory, it should first calculate all its needed memory bytes, from this, I think all memory allocated should be used and from its description for the PrivateMemorySize64, its value returned by this property represents the current size of memory used by the process, my opinion is that this property should already show the actual memory in private bytes.

    If I do not understand correctly, please feel free to let me know.

    Regards.


    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, March 10, 2015 7:25 AM
    Moderator
  • "As I understand Process "PrivateMemorySize64" (process.PrivateMemorySize64) contains unused memory allocated by CLR."

    Yes but that's not specific to CLR, this is true about all practical memory allocators.

    "Is there a way, I can program and find the amount of unused memory in private bytes using C#?"

    Not with the Process class and not easily. There are CLR GC performance counters that can provide more information about memory usage but they're strictly about the GC heap. The CLR also allocates memory that's not part of the GC heap and it will be quite difficult or impossible to put every bit of information together to obtain what you want.

    "I am selecting the process from another process and listing memory size. but since private byte also contains the "unused memory" allocated by clr, it is getting difficult for me to find the actual memory consumed by process."

    The actual memory consumed by a process is really PrivateMemorySize64. As far as the OS is concerned that is committed memory and it's irrelevant that some of that committed memory isn't actually used by the process.

    Wednesday, March 11, 2015 10:43 AM
    Moderator