Re: Assembly memory limit exception -WHY?

Tech-Archive recommends: Speed Up your PC by fixing your registry




"Dan Neely" <DanNeely@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:97B99583-C6DC-46B6-87B3-FA2C63E414BC@xxxxxxxxxxxxxxxx
>
>
> "Nicholas Paldino [.NET/C# MVP]" wrote:
>> I don't think that is necessarily the problem. With arrays, the
>> memory
>> has to be continuous. Asking for 700-800 MB of continuous memory is a
>> lot,
>> and to be quite frank, not the best way to go about this.
>
> I'm not sure that's it. IIRC the memory is only guaranteed contigious
> within the applications address space, and that there's no way to assure
> that
> it maps to contigious blocks at the OS level.

Sure it is, and that is exactly what Nicolas meant, the address space
allocated to a process (VAS) is limited to 2GB on 32 bit windows (or 3GB
when 3GB tuning is enabled).

This 2GB address space is used to load all application components:
1. C Runtime DLL's, CLR DLL's and Windows system DLL's and private user
DLL's (if any)
2. The native heap space allocated by the system DLL's and the C runtime and
the CLR.
3. The managed heap allocated by the CLR
4. The loaded managed assemblies (note these aren't loaded as normal win32
DLL's).
5. The compiled pages from the JIT compilation of 4.

The results is that a process that hosts the CLR has ~1.5 MB of total free
heap space at process start, however this space is guaranteed to be
fragmented and the largest fragment is not going to be larger than ~1.2 GB.
It might be a lot smaller if some DLL gets mapped in the middle of this
address space.
>From this 1.2GB the CLR will allocate it's Large Object heap, which by
itself might get fragmented because this LOH is never compacted by the GC.
Now what the OP didn't say is how many objects did get allocated before he
creates that large 800MB object (an array?), also I'm not sure where he gets
this size from (a wild guess?).
Not that the popular ArrayList are really heap hungry, suppose the OP stores
its data in a Arraylist that gets filled up to it's full 700MB, when the
application tries to insert more data into the ArrayList , the list will
grow by it's standard factor 2, so the CLR will need 1.4GB to accommodate
the list, and will throw an OOM exception because this space isn't available
(as one large chunk).

Willy.


.



Relevant Pages

  • Re: Struct inside class
    ... The compiler figures computes the ... including anything derived from "Object": Heap pointer ... memory leaks and why the .NET good garbage collector is required. ... If GC_ALLOCATE can't allocate the requested ...
    (microsoft.public.dotnet.framework)
  • Re: run-time vs compile-time
    ... > offset related to some location (like stack base) somewhere. ... > offset from heap to pi. ... When you allocate an int on the heap, it is allocated at address 1. ... application has a given amount of memory it can use as it wishes. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: run-time vs compile-time
    ... > offset related to some location (like stack base) somewhere. ... > offset from heap to pi. ... When you allocate an int on the heap, it is allocated at address 1. ... application has a given amount of memory it can use as it wishes. ...
    (comp.lang.cpp)
  • Re: Huge pages and small pages. . .
    ... >> what looks like contiguous memory and away you go. ... you need to have them cached in the TLB; if the TLB runs out of ... > low end of the heap, until someone figures out a way to tell the system ... When you allocate memory, the kernel just marks a promised ...
    (Linux-Kernel)
  • Re: GC.Collect can be trusted?
    ... compact the heap. ... It's not the task of the GC to return the memory to the OS, ... contain any GC heap data (managed objects and other CLR data). ... the memory manager won't ever return the default process heap segments occupied by ...
    (microsoft.public.dotnet.languages.csharp)