Skip to content

Total memory usage doesn't work in linux/docker containers #30

@farkas1121

Description

@farkas1121

I'm using pterodactyl panel on linux to run my servers and noticed that server metrics reports the total memory usage to be 0.
It seems like Rust's native dll returns the wrong value trough SystemInfoEx.systemMemoryUsed.

One possible way to avoid this issue would be to get the list of processes and sum their memory usage like this.

            using System.Diagnostics;

            long memoryUsageBytes = 0;
            foreach (var process in Process.GetProcesses())
            {
                memoryUsageBytes += process.WorkingSet64;
            }

Or just get the memory usage of the current server like this:

            using System.Diagnostics;

            Process currentProcess = Process.GetCurrentProcess();
            long memoryUsageBytes = currentProcess.WorkingSet64;

Not sure whether there are any downsides or a better solution, but I think it would be worth it to look into a new way of getting the memory usage on linux systems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions