Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9243835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:53:49+00:00 2026-06-18T08:53:49+00:00

How do I get the total memory used by my C# application? I have

  • 0

How do I get the total memory used by my C# application?
I have tried:
GC.GetTotalMemory()
Process.GetCurrentProcess().PrivateMemorySize, PrivateMemorySize64,
VirtualMemorySize, VMS64, PagedMS.

They do report various values, which is OK. But these values differ from what I see in the Task Manager.

I am using Windows 8 and the task manager shows resources used by all apps separately on the right hand side besides the application name.
My Application’s current memory is also displayed. Suppose it is 18.9 MB, and drops down to say ~9 MB if I force a GC.Collect().

Now,
before GC.Collect():
PrivateMemorySize & PMS64 both report ~42 (after converting to MB)
and GetTotalMemory() gives ~3
PagedMS & PagedMS64 gives ~379

and after GC.Collect():
PrivateMemorySize & PMS64 both report ~39 (after converting to MB)
and GetTotalMemory() gives ~1
PagedMS & PagedMS64 gives ~367

But these are different from task manager’s display. What I want to get is the ‘18.9’ and ‘9’ ie. the memory usage of my application as reported by the windows 8 task manager.
How do I do this through code behind?
I use .Net 4.0, visual studio 2012

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:53:50+00:00Added an answer on June 18, 2026 at 8:53 am

    I’d not try to replicate what taskmgr does but use the number that logically makes sense for you. Probably, that’s private bytes (of course, use the 64 bit version). Private bytes are those bytes that are actually in use and that are not shared with any other process.

    There is no memory number that is perfect (neither on Windows nor on Linux) because memory usage is open to interpretation as soon as multiple processes share some pages.

    Private bytes is very appropriate for most apps, though.

    Update: The Windows 8 Task Manager shows Working Set Private Bytes. This is an awful metric to use. It tells you how much memory of this app is currently in RAM. This can be much less than actual memory usage. It does not tell you how much memory will be freed if this process exits.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to get total memory in bytes used by OpenGL in C++? I'm building
To get the total memory used by SQL CLR, you would run the following
There is a way to get the total memory PHP is using ( memory_get_usage()
How can I get the total physical memory in bytes of my Linux PC?
How can I get the Total memory usage by all running applications? Basically I
Using PHP, I'd like to get the total memory available to the system (not
How could I get the total amount of memory, that allocated by FastMM? I've
I have been playing around with GC.GetTotalMemory(). When I create a local variable of
I'm trying to get total salary for the whole company by: NSNumber *totalSalary =
I want to get total row count in iReport. The intention is to print

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.