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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:41:43+00:00 2026-05-12T09:41:43+00:00

My code: var list = new LinkedList<int>(); var ramCounter = new PerformanceCounter(Memory, Available MBytes);

  • 0

My code:

var list = new LinkedList<int>();
var ramCounter = new PerformanceCounter("Memory", "Available MBytes");
while (true)
{
    for(int i = 0; i < 1000 * 1000; i++) list.AddLast(0);
    Console.WriteLine(ramCounter.NextValue());
}

Questions:

  1. The documentation seems to say I can use a PerformanceCounter only as an Administrator, but I ran my application as a Standard User and it worked. Can I rely on that?
  2. I consistently get OutOfMemoryException when about 200 MB RAM remain, why? It can’t be due to fragmentation because I allocate an int at a time. Also, it can’t be because of addressability issues, as I’m already way above 2GB (the exception gets thrown when 2.8 out of my 3GB are taken). The numbers output by the test app were verified with a Task Manager window running at the side.
  3. Once I got a BSOD when the test app was running and about 400 MB were remaining. Any hints as to what could possibly cause this? I’ll run a check for RAM integrity, anything else? Should I be careful with calling PerformanceCounter.NextValue() in a loop, or something? Note, that’s the first time I get a BSOD on this PC.
  4. At some points in the program execution, I get big delays. E.g. when I start at 1 GB free RAM, when I get to 700 MB the app freezes for 1 sec, then at about 400 MB it freezes for about 4 sec. Why is this? Because the OS needs to swap out disk caches to free up memory, or something?

Note: Why am I doing this? Well, I want my memory-intensive app to detect when 5 MB RAM remain, and alert the user with “Memory is low, please close other programs and come back, or this program will fail.”

  • 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-05-12T09:41:43+00:00Added an answer on May 12, 2026 at 9:41 am

    I can’t address all your questions, but here goes

    2) Are you on 32 or 64 bit Windows? It sounds like you’re running a large address aware process with access to 3 GB (i.e. on 32 bit Windows). In any case you have to keep in mind that memory is allocated in chucks of various sizes and your heap usage is not the only source. The CLR itself has numerous structures, each thread has a stack and so on. In any case, you can’t really expect to be able to use exactly 3 GB,

    3) BSOD is due to driver or kernel errors. AFAIK your application cannot cause BSOD, so this is most likely unrelated.

    4) If you use a lot of memory the GC will have a hard time keeping up. As user threads are suspended while certain parts of GC is in progress this will slow down your application significantly.

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

Sidebar

Related Questions

i have this code: var list = new List<int>(); for(int i=0;i<10;i++) list.Add(i); for(int i=0;i<10;i++)
Let me explain using this code sample: var commands1 = new List<int> { 1
Given the following code: var people = new List<person>(){ new person { Name =
Given the following code: var myList = new List<string> { red, blue, green };
Given the following code: var myList = new List<string> { red shirt, blue, green,
I've the following code: var e = someList.GetEnumerator(); var a = new List<Foo>(); var
I got a list: var list = new List<List<int>>(); which could contain list[0] =
Suppose I have this code: var myArray = new Object(); myArray["firstname"] = "Bob"; myArray["lastname"]
in the following code : var benq:Base64Encoder = new Base64Encoder(); benq.encode(force,0,5); var tmp:String =
Namely, how does the following code: var sup = new Array(5); sup[0] = 'z3ero';

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.