Skip to content

PrivateMemorySize64 #23284

Closed
Closed

Description

@Jimmy062006

Writing code in Dotcore 2.0 and trying to use Process.GetCurrentProcess().PrivateMemorySize64 on Linux will yield 0 as a result where by Windows OS's return the expected results.

Is this intended ?

Activity

  1. TAGC commented on Aug 21, 2017

    @TAGC

    This issue can be reproduced in microsoft/dotnet:2.0-sdk:

    // Program.cs
    
    using System;
    using System.Diagnostics;
    
    namespace experiment
    {
        class Program
        {
            static void Main()
            {
                var memorySize = Process.GetCurrentProcess().PrivateMemorySize64;
                Console.WriteLine($"Private memory: {memorySize}");
            }
        }
    }
    # Dockerfile
    
    FROM microsoft/dotnet:2.0-sdk
    WORKDIR /app
    COPY . .
    ENTRYPOINT dotnet run

    Output

    $ docker build . -q -t temp && docker run --rm temp
    sha256:c3891ad59b7adf4db4dfb3d41b68fe015bfeab4a031740ad8692d343db7e492e
    Private memory: 0
    
  2. danmoseley commented on Aug 21, 2017

    @danmoseley
    Contributor

    It seems to me the code could be improved to do as it says, at least fill it in for the current process. @Jimmy062006 was that what you needed it for?

  3. danmoseley commented on Aug 21, 2017

    @danmoseley
    Contributor

    @stephentoub may be able to remember why he didn't do that.

  4. stephentoub commented on Aug 21, 2017

    @stephentoub
    Member

    It's basically reading from "/proc/{pid}/status" file.

    This code reads from procfs. Which value maps to what's needed here?

  5. stephentoub commented on Aug 21, 2017

    @stephentoub
    Member

    Does VmData actually represent the same value as all non-shared memory?

  6. stephentoub commented on Aug 21, 2017

    @stephentoub
    Member

    with shared and stack pages subtracted.

    Is it the right value then if stack is excluded? Is stack not included in PrivateMemorySize on Windows?

  7. stephentoub commented on Aug 21, 2017

    @stephentoub
    Member

    (Regardless, if the right values are available, it'd make sense to use that data to better populate the info object... though I think I'd want to see statm parsed rather than status.)

  8. JustArchi commented on Aug 23, 2017

    @JustArchi
    Contributor

    If we need stack size we can very easily add value of VmStk from the same /proc/{pid}/status data to total VmData in order to get VmData + stack size. Not like it'll make the value that much different anyway, but if Windows does that, then we can do it too.

  9. Jimmy062006 commented on Aug 29, 2017

    @Jimmy062006
    Author

    @danmosemsft I wanted to use it on a status command in the app I'm writing.

    I then found out it worked fine in Windows but not Linux. So yes :)

  10. danmoseley commented on Aug 29, 2017

    @danmoseley
    Contributor

    Does anyone on this thread want to take a shot at implementation? If so I will assign you the issue!

  11. 4 remaining items

  12. tannergooding commented on Aug 29, 2018

    @tannergooding
    Member

    @danmosemsft, should this be marked up for grabs?

  13. danmoseley commented on Aug 29, 2018

    @danmoseley
    Contributor

    Sure

  14. self-assigned this
    on Mar 28, 2019
  15. karelz commented on Dec 19, 2019

    @karelz
    Member

    Fixed in 3.1 in PR dotnet/corefx#42370 and in 5.0 (master) in PR dotnet/corefx#41122

  16. transferred this issue fromdotnet/corefxon Jan 31, 2020
  17. added this to the 3.1 milestone on Jan 31, 2020
  18. thevioletsaber commented on Jun 17, 2020

    @thevioletsaber

    Is there any plan to bring this fix to OSX as well? I'm currently using the WorkingSet64 property but that overestimates the amount of memory consumed.

  19. ghost locked as resolved and limited conversation to collaborators on Dec 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-System.Diagnostics.Processbughelp wantedos-linuxos-macos

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions