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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -