Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

OutOfMemoryException When Allocating Huge Objects That Use Lots of     RAM on 64-bit Machine

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
powwow - 26 Mar 2008 18:09 GMT
I am running out of memory (OutOfMemoryException) when I do something
like this:

Hashtable h = new Hashtable(10000000);

It doesn't seem to use all of the RAM on the machine.  I have 4GB of
RAM installed.

I have a 64 bit OS (Windows Vista).  I have 64 bit CPU. (Intel Quad
Core).  So no 32-bit restriction argument applies here.

I am using Visual Express 2008 C#.  Since it doesn't come with
editbin.exe I had to download Visual Express 2008 C++ and use it's
editbin.exe on my C# executable.

I executed "editbin /LARGEADDRESSAWARE program.exe"  But when I run
program.exe it runs out of memory when I know there is RAM not being
used.

WHAT GIVES?   PLEASE HELP.  I feel like I bought a 64-bit machine for
nothing since the sole purpose was to allocate more memory than a 32-
bit OS.
Willy Denoyette [MVP] - 26 Mar 2008 18:53 GMT
>I am running out of memory (OutOfMemoryException) when I do something
> like this:
[quoted text clipped - 18 lines]
> nothing since the sole purpose was to allocate more memory than a 32-
> bit OS.

Are you sure about this?
(10000000);

This value should not be a problem, even on 32-bit it should be fine.
Please post a complete sample that illustrates the issue.

Willy.
powwow - 26 Mar 2008 19:45 GMT
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.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.