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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 197k
  • Answers 197k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer To remove the toolbar you have to change the DocumentViewer's… May 12, 2026 at 7:17 pm
  • Editorial Team
    Editorial Team added an answer There are some docs at: http://cxf.apache.org/docs/jmx-management.html about how to enable… May 12, 2026 at 7:17 pm
  • Editorial Team
    Editorial Team added an answer One thing that has caught me out in the past… May 12, 2026 at 7:17 pm

Related Questions

The code below is extremely slow for tables of any significant size. (100, 1000,
I'm trying to do my linq 2 sql objects manually, so I have the
I am getting a strange exception when trying to update a DataTable after flagging
I'm trying to parse results from the YouTube API. I'm getting the results correctly

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.