AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 103814
Accepted
Andrew J. Brehm
Andrew J. Brehm
Asked: 2010-01-19 08:00:35 +0800 CST2010-01-19 08:00:35 +0800 CST 2010-01-19 08:00:35 +0800 CST

使用 Powershell 找出占用大量内存的内容(在 64 位 Windows 上)

  • 772

我如何找出(在 Powershell 中)哪个进程/什么使用最多的内存?

编辑:我试图弄清楚如何使用 Powershell 找出所有物理内存的使用情况,以防任务管理器等无法解释为什么所有物理 RAM 都已用完。即我需要识别缓存等使用的内存。

windows powershell
  • 3 3 个回答
  • 61637 Views

3 个回答

  • Voted
  1. Best Answer
    squillman
    2010-01-19T08:22:44+08:002010-01-19T08:22:44+08:00

    这是一种获取当前正在运行的进程的信息并按工作集大小排序的方法

    Get-Process | Sort-Object -Descending WS
    

    将该输出分配给一个变量,它会给你一个结果数组,然后你可以写出数组的第一个成员(在这种情况下将是一个System.Diagnostics.Process对象)。

    $ProcessList = Get-Process | Sort-Object -Descending WS
    Write-Host $ProcessList[0].Handle "::" $Process.ProcessName "::" $Process.WorkingSet
    

    这是另一个使用 WMI 的 Win32_Process 提供程序从当前正在运行的进程列表中转储一些数据的快速而肮脏的脚本:

    $ProcessList = Get-WmiObject Win32_Process -ComputerName mycomputername
    foreach ($Process in $ProcessList) {
        write-host $Process.Handle "::" $Process.Name "::" $Process.WorkingSetSize
    }
    

    这将列出 PID(句柄)、进程名称和当前工作集大小。您可以使用WMI Process 类的不同属性对其进行更改。

    • 10
  2. Eric
    2016-07-13T12:57:37+08:002016-07-13T12:57:37+08:00

    一个班轮找到你最高内存使用进程的名称

    Get-Process | Sort-Object -Descending WS | select -first 1 | select -ExpandProperty ProcessName
    
    • 2
  3. Suresh
    2016-07-13T12:48:49+08:002016-07-13T12:48:49+08:00
    $scripthost = Read-Host "Enter the Hostname of the Computer you would like to check Memory Statistics for"
    ""
    ""
    "===========CPU - Top 10 Utilization List==========="
    gwmi -computername $scripthost Win32_PerfFormattedData_PerfProc_Process| sort PercentProcessorTime -desc | select Name,PercentProcessorTime | Select -First 10 | ft -auto
    "===========Memory - Top 10 Utilization List==========="
    gwmi -computername $scripthost Win32_Process | Sort WorkingSetSize -Descending | Select Name,CommandLine,@{n="Private Memory(mb)";Expression = {[math]::round(($_.WorkingSetSize / 1mb), 2)}} | Select -First 10 | Out-String   
    #gwmi -computername $scripthost Win32_Process | Sort WorkingSetSize -Descending | Select Name,CommandLine,@{n="Private Memory(mb)";e={$_.WorkingSetSize/1mb}} | Select -First 10 | Out-String
    #$fields = "Name",@{label = "Memory (MB)"; Expression = {[math]::round(($_.ws / 1mb), 2)}; Align = "Right"}; 
    
    "===========Server Memory Information==========="
    $fieldPercentage = @{Name = "Memory Percentage in Use (%)"; Expression = { “{0:N2}” -f ((($_.TotalVisibleMemorySize - $_.FreePhysicalMemory)*100)/ $_.TotalVisibleMemorySize)}};     
    $fieldfreeram = @{label = "Available Physical Memory (MB)"; Expression = {[math]::round(($_.FreePhysicalMemory / 1kb), 2)}}; 
    $fieldtotalram = @{label = "Total Physical Memory (MB)"; Expression = {[math]::round(($_.TotalVisibleMemorySize / 1kb), 2)}}; 
    $fieldfreeVram = @{label = "Available Virtual Memory (MB)"; Expression = {[math]::round(($_.FreeVirtualMemory / 1kb), 2)}}; 
    $fieldtotalVram = @{label = "Total Virtual Memory (MB)"; Expression = {[math]::round(($_.TotalVirtualMemorySize /1kb), 2)}}; 
    $memtotal = Get-WmiObject -Class win32_OperatingSystem -ComputerName $scripthost; 
    $memtotal | Format-List $fieldPercentage,$fieldfreeram,$fieldtotalram,$fieldfreeVram,$fieldtotalVram;
    
    • 0

相关问题

  • Vanilla Powershell 是否足以成为 Windows 和 DB 服务器管理员的语言?

  • 为什么添加新驱动器后我的磁盘驱动器访问速度如此之慢?

  • 在 Windows Server 2003 下使用 wscipt 从 .asp 文件运行 .exe

  • 最佳混合环境(OS X + Windows)备份?[关闭]

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    从 IP 地址解析主机名

    • 8 个回答
  • Marko Smith

    如何按大小对 du -h 输出进行排序

    • 30 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    MikeN 在 Nginx 中,如何在维护子域的同时将所有 http 请求重写为 https? 2009-09-22 06:04:43 +0800 CST
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    0x89 bash中的双方括号和单方括号有什么区别? 2009-08-10 13:11:51 +0800 CST
  • Martin Hope
    Kyle Brandt IPv4 子网如何工作? 2009-08-05 06:05:31 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve