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 8984757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:11:02+00:00 2026-06-15T21:11:02+00:00

i wish to make a Listener will watch/Track RAM Usage. I know that in

  • 0

i wish to make a Listener will watch/Track RAM Usage.

I know that in C# we can get the Working Usage using

  public static class PerformanceInfo
  {
      [DllImport("psapi.dll", SetLastError = true)]
      [return: MarshalAs(UnmanagedType.Bool)]
      public static extern bool GetPerformanceInfo([Out] out PerformanceInformation       PerformanceInformation, [In] int Size);

      [StructLayout(LayoutKind.Sequential)]
      public struct PerformanceInformation
      {
        public int Size;
        public IntPtr CommitTotal;
        public IntPtr CommitLimit;
        public IntPtr CommitPeak;
        public IntPtr PhysicalTotal;
        public IntPtr PhysicalAvailable;
        public IntPtr SystemCache;
        public IntPtr KernelTotal;
        public IntPtr KernelPaged;
        public IntPtr KernelNonPaged;
        public IntPtr PageSize;
        public int HandlesCount;
        public int ProcessCount;
        public int ThreadCount;
      }

      public static Int64 GetPhysicalAvailableMemoryInMiB()
      {
          PerformanceInformation pi = new PerformanceInformation();
          if (GetPerformanceInfo(out pi, Marshal.SizeOf(pi)))
          {
            return Convert.ToInt64((pi.PhysicalAvailable.ToInt64() * pi.PageSize.ToInt64() / 1048576));
          }
          else
          {
            return -1;
          }

      }

      public static Int64 GetTotalMemoryInMiB()
      {
        PerformanceInformation pi = new PerformanceInformation();
        if (GetPerformanceInfo(out pi, Marshal.SizeOf(pi)))
        {
          return Convert.ToInt64((pi.PhysicalTotal.ToInt64() * pi.PageSize.ToInt64() / 1048576));
        }
        else
        {
          return -1;
        }

      }
    }
  }    

No this listener should track the RAM USAGE EVEry Second and if its greater than the specified %age then it should Kill Some Processes or should provide some notification to my App (WPF app) to kill some specific processes

How can i make a piece of code constantlr listen to sytem and then invoke some actions

Any help in this regard would be great..

  • 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-15T21:11:04+00:00Added an answer on June 15, 2026 at 9:11 pm

    Use on of Timer classes. Like System.Timers.Timer or even simple Thread.Sleep(1000) will be ok (assuming your code runs on seprate non-UI thread).

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

Sidebar

Related Questions

Lets say I wish to make a page that can query the desired object
I wish to make sure that my data has a constraint the following check
I have a large system that I have coded and I wish to make
I am using jQuery, and wish to make certain links open in a new
I'm working on my high-school matriculation asp.net project, and I wish to make a
We wish to make a desktop application that searches a locally packaged text database
I wish to make something that cuts the name to e.g: Alex Andersson to
I wish to make a call in Node.js somethine like this (i m using
I'm in the middle of this C project that I wish to make very
I wish to make an AJAX call using jQuery as a heartbeat in the

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.