Get memory size from task manager?

Posted on 2009-04-17
Last Modified: 2012-05-06
Hi there

Wonder if you can help me?

I have a console app written in C#/2005, in Task manager I can see the console app being run, and as you know the task manager shows the Mem Usage. How do I get the mem usage value for that console application and store that as a variable?

Question by:mousemat24
    1 Comment
    LVL 39

    Accepted Solution

    try the following:

       long totalMem = GC.GetTotalMemory(false);

    if the returned value is not equal to the one in TaskManager, don't be alarmed, this is the memory your application is actually using, but the GC and CLR might have more memory (pre) allocated.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now