python 2.7 - Process and subprocesses information(memory) -
get-process -id <pid> returns information specific process, invoked process.
is there way know memory taken process , processes created process?
in powershell you'd define recursive function enumerate child processes of given process:
function get-childprocesses { [cmdletbinding()] param( [parameter(mandatory=$true, valuefrompipeline=$true)] [int[]]$processid ) process { $processid | foreach-object { $_ get-wmiobject -class win32_process -filter "parentprocessid=$_" | select-object -expand processid | get-childprocesses } } } then call get-process pids , expand memory information:
get-process -id (get-childprocesses 123) | select-object -expand workingset replace workingset virtualmemorysize if want total allocated virtual memory of processes rather physical memory they're using @ time.
in python you'd use module psutil, jean-françois fabre suggested in comments.
import psutil parent = psutil.process(123) child in parent.children(recursive=true): print(child.memory_info().rss) replace rss vms if want total allocated virtual memory of processes rather physical memory they're using @ time.
Comments
Post a Comment