Re: Memory Limit for Visual Studio 2005???

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



That's not one 1 gig.

That's 1GB * 4 bytes per int, for a total of 4 gigs. This is never, ever,
going to run on an x86 system.

--
Chris Mullins

"Peter Olcott" <NoSpam@xxxxxxxxxxxxx> wrote in message
news:CnXih.158245$HO4.61758@xxxxxxxxxxxxxxx
Try this simpler case:
uint SIZE = 0x3FFFFFFF; // 1024 MB

List<uint> Temp;
for (uint N = 0; N < SIZE; N++)
Temp.Add(N);

Mine now bombs out on just short of half my memory. I am guessing that it
runs out of actual RAM when it doubles the size on the next reallocation.
Unlike the native code compiler, the managed code compiler must have
actual RAM, virtual memory will not work.

"Chris Mullins" <cmullins@xxxxxxxxx> wrote in message
news:eW33XxfJHHA.5104@xxxxxxxxxxxxxxxxxxxxxxx
Peter Olcott Wrote:

PO> It looks like System::Collections::Generic.List throws and
PO> OUT_OF_MEMORY exception whenever memory allocated exceeds 256 MB. I
PO> have 1024 MB on my system so I am not even out of physical RAM, much
PO> less virtual memory.

I was curious if there was a limt there, so I wrote this:

private void button1_Click(object sender, EventArgs e)
{
int bytesPerArray = 1024 * 32; // 32k per byte. No large object heap
interaction.
long totalBytes = 0;
List<byte[]> bytes = new List<byte[]>();
while (true)
{
byte[] b = new byte[bytesPerArray];
bytes.Add(b);
totalBytes += bytesPerArray;
System.Diagnostics.Debug.WriteLine("Total: " +
totalBytes.ToString());
}
}

I compiled this as an x86 application, and ran it.

In my output window, the last things in there was:
Total: 1704427520
A first chance exception of type 'System.OutOfMemoryException'
occurred in WindowsApplication2.exe

This is exactly what I expected to see, as I know that each 32-bit
Windows Process gets 4GB of virual memory space, and that 4GB is split in
half, giving 2GB to user code to play with. The managed heap can
typically (if it's not fragmented) get up to 1.5-1.7 gigabytes before
issues arise.

If I compile this for x64 (or leave it as Any CPU), the limites are much
higher.

My machine does have 4GB of memory on it, but I've seen these exact same
results on machines with far less memory. (I build very big, very
scalable, applications all day long... and running into memory
limitiations in 32-bit land was a big problem I had for years).

--
Chris Mullins, MCSD.NET, MCPD:Enterprise
http://www.coversant.net/blogs/cmullins






.


Quantcast