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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:44:38+00:00 2026-05-11T07:44:38+00:00

My memory is 4G physical, but why I got out of memory exception even

  • 0

My memory is 4G physical, but why I got out of memory exception even if I create just 1.5G memory object. Any ideas why? (I saw at the same time, in the performance tab of task manager the memory is not full occupied, and I could also type here — so memory is not actually low, so I think I hit some other memory limitations)?

using System; using System.Collections.Generic; using System.Linq; using System.Text;  namespace TestBigMemoryv1 {     class MemoryHolderFoo     {         static Random seed = new Random();         public Int32 holder1;         public Int32 holder2;         public Int64 holder3;          public MemoryHolderFoo()         {             // prevent from optimized out             holder1 = (Int32)seed.NextDouble();             holder2 = (Int32)seed.NextDouble();             holder3 = (Int64)seed.NextDouble();         }     }      class Program     {         static int MemoryThreshold = 1500; //M         static void Main(string[] args)         {             int persize = 16;             int number = MemoryThreshold * 1000 * 1000/ persize;             MemoryHolderFoo[] pool = new MemoryHolderFoo[number];             for (int i = 0; i < number; i++)             {                 pool[i] = new MemoryHolderFoo();                 if (i % 10000 == 0)                 {                     Console.Write('.');                 }             }              return;         }     } } 
  • 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. 2026-05-11T07:44:39+00:00Added an answer on May 11, 2026 at 7:44 am

    In a normal 32 bit windows app, the process only has 2GB of addressable memory. This is irrelevant to the amount of physical memory that is available.

    So 2GB available but 1.5 is the max you can allocate. The key is that your code is not the only code running in the process. The other .5 GB is probably the CLR plus fragmentation in the process.

    Update: in .Net 4.5 in 64 bit process you can have large arrays if gcAllowVeryLargeObjects setting is enabled:

    On 64-bit platforms, enables arrays that are greater than 2 gigabytes (GB) in total size. The maximum number of elements in an array is UInt32.MaxValue.

    <configuration>   <runtime>     <gcAllowVeryLargeObjects enabled='true' />   </runtime> </configuration> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two processes which access to the same physical memory(GPIO data addr). So
A raw computer basically just has memory with physical addresses starting at 0, right?
There is sometimes a problem with running out of memory when it got fragmented.
I'm trying to access physical memory directly for an embedded Linux project, but I'm
My .NET CF 3.5 application receives an Out of memory exception when DOM processing
I'm accessing my memory-mapped device via a device-specific physical memory on the PC. This
How can I get the total physical memory in bytes of my Linux PC?
What factors determine the maximum amount of physical memory a system can have? I
My understanding is that shadow page tables eliminate the need to emulate physical memory
I would like to obtain, from within the Python program, the maximum physical memory

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.