40186

Memory usage and time for execution for another process using C#?

I need the memory usage and processing time for an application loaded through another application. I am using C#. Currently I am using Process.WorkingSet to get memory usage similarly Process.TotalProcessTime to get time for execution, but it doesn't give any value. So have you make any suggestions?

Answer1:

Use WMI to get this kind of info, well supported by the System.Management namespace. Get started by downloading the WMI Code Creator utility, it lets you experiment with queries and can auto-generate the C# you'll need.

You want to query Win32_Process, it provides lots of info about a process. PrivatePageCount would be a good measure for the amount of memory it uses that isn't shared by any other process. KernelModeTime and UserModeTime gives you time spent executing code.

Recommend

  • Python: Cross-platform solution to detect physical non-HT CPUs?
  • Detect Removable Media Ejection Request in Windows Service
  • How to get OS version and Device Name of an Android device connected via USB with C#.net (VS2010/4.0
  • Jsoup parsing an Html file with a tbody tag
  • c#.NET USB device persistent identifier
  • how to create a downloadable csv file in appengine
  • WCF hosting issues
  • dismiss Progress Dialog in another Activity … Android
  • C++ Coin flip program error
  • string.IsNullOrEmpty() Doesn't Seem to Work on a String within a Class within a Class
  • Return null in boolean to checkbox state converter in XAML
  • Azure table query partial partitionkey guid match
  • SIP API media codecs
  • New Firebase failed: First argument must be a valid firebase URL and the path can't contain “.”
  • JSON encode and decode on PHP
  • Building Qt project for C++11 standard
  • NHibernate manually control fetching
  • Does Apportable support to build library binary (.a/.so)?
  • WPF Template Binding in ToggleButton UserControl
  • How can I replace the server in Web Component Tester
  • Clear activity stack before launching another activity
  • Sending keystrokes/mouse clicks to a Java program with Autohotkey
  • Jenkins: FATAL: Could not initialize class hudson.util.ProcessTree$UnixReflection
  • How to match http request and response using Jersey ContainerRequestFilter and ContainerResponseFilt
  • Record samples being played with OpenAL
  • Yii2: Config params vs. const/define
  • Ajax Loaded meta Tags
  • How to rebase a series of branches?
  • Linq Objects Group By & Sum
  • Different response to non-authenticated users and AJAX calls
  • Optimizing database types to compact database (SQLite)
  • Knitr HTML Loop - Some HTML output, some R output
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Proper folder structure for lots of source files
  • Buffer size for converting unsigned long to string
  • KeystoneJS: Relationships in Admin UI not updating
  • How does Linux kernel interrupt the application?
  • Checking variable from a different class in C#
  • reshape alternating columns in less time and using less memory