Thanks for the reply. I have supplied the example below. When I run
with 60000000 it doesn't seem to use all the memory.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Test
{
class Program
{
static void Main(string[] args)
{
Hashtable h = new Hashtable(70000000); //This will cause
System.OutOfMemoryException
//60000000 seems to work but not 70000000
}
}
}
Again, I am running 64-bit machine, 64 bit OS, Visual Express C# 2008
with 4GB RAM. I also use editbin /LARGEADDRESSAWARE on the exe.
Still there is an out of memory error.
On Mar 26, 10:53 am, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.be> wrote:
> >I am running out of memory (OutOfMemoryException) when I do something
> > like this:
[quoted text clipped - 26 lines]
>
> Willy.
Doug Forster - 26 Mar 2008 21:25 GMT
AFAIK individual objects are limited to 2GB even for the 64bit framework
(and yes this is a dumb restriction). I can only speculate that your
specified capacity causes this limit to be exceeded for some reason. The
LARGEADDRESSAWARE flag and the amount of RAM you have are irrelevant.
Cheers
Doug Forster
> Thanks for the reply. I have supplied the example below. When I run
> with 60000000 it doesn't seem to use all the memory.
[quoted text clipped - 56 lines]
>>
>> Willy.
Willy Denoyette [MVP] - 26 Mar 2008 22:33 GMT
Oh, but this is something different, 60000000 means an Hashtable of about
2.000.000.000 bytes of contagious memory, which is about the maximum size of
a single object on .NET (2GB).
Note that in your sample you don't insert any element in the table,when you
start adding elements to the table you will see the memory consumption grow
even above 4GB depending on the type and size of elements your are adding.
So while you can't create single objects that are larger than 2GB, you can
easily allocate a TB of data by using a container like a Hashtable.
Just try to add 60000000 elements (say an int string pair) to your table,
and watch your system grinding to halt, this because you are consuming more
than the available RAM memory, so that your system starts paging like mad.
Don't be surprised that the program never reached the end, the program will
fail if when all virtual memory (RAM + pagefile size) is consumed.
Some systems even crash when no more VM is left, you are warned ;-).
Willy.
> Thanks for the reply. I have supplied the example below. When I run
> with 60000000 it doesn't seem to use all the memory.
[quoted text clipped - 56 lines]
>>
>> Willy.
Jeroen Mostert - 26 Mar 2008 23:34 GMT
> Oh, but this is something different, 60000000 means an Hashtable of
> about 2.000.000.000 bytes of contagious memory, which is about the
> maximum size of a single object on .NET (2GB).
Good thing, too, before that memory starts to infect the rest. :-)
Do you have an autocorrecting spell-checker, by any chance? I could see it
making "contagious" out of anything that doesn't resemble "contiguous" enough.

Signature
J.
Willy Denoyette [MVP] - 27 Mar 2008 00:07 GMT
>> Oh, but this is something different, 60000000 means an Hashtable of
>> about 2.000.000.000 bytes of contagious memory, which is about the
[quoted text clipped - 5 lines]
> making "contagious" out of anything that doesn't resemble "contiguous"
> enough.
You (and I) don't want to see my auto-correcting spell-checker turned on
:-), the result is some mix of Dutch , French and English.
I think it's just time to get some sleep that's all.
Willy.