Re: is there some per-process-limit on memory in .net processes?



"Doug Semler" <dougsemler@xxxxxxxxx> wrote in message news:%23jyQBt69HHA.5404@xxxxxxxxxxxxxxxxxxxxxxx
"Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx> wrote in message news:%238MVTv39HHA.4612@xxxxxxxxxxxxxxxxxxxxxxx
"Doug Semler" <dougsemler@xxxxxxxxx> wrote in message news:eFRstt09HHA.700@xxxxxxxxxxxxxxxxxxxxxxx
"Daniel" <softwareengineer98037@xxxxxxxxx> wrote in message news:%23Y94rm09HHA.5424@xxxxxxxxxxxxxxxxxxxxxxx
is there some per-process-limit on memory in .net processes? is there any way to increase it? i keep getting System.OutOfMemoryException when my box has 8 gigs of unused memory.


A 32 bit process can only address 2 GB. Doesn't matter how much memory you have on your system, the limit is the process. . That being said, you probably will only see a max 1.6 GB max allocation (32 bit) due to other factors... and due to memory fragmentation you'll probably not be able to allocate a block larger than what, 1GB or so?

If you want to be able to get over that limitation, you'll need to run it on a 64 bit processor in a 64 bit process. 32 bit processes even on a 64 bit machine still suffer the ame limitation since the process still sees everyting '32 bits'.


Doug must learn to proofread. <g> I *meant* to say 32 bit processes still suffer a similar limitation on x64. (but it's 4 gb not 2)


Not really, on 64 bit Windows the "system portion" is no longer mapped into the process virtual address space, that means that a 32 bit process enjoys a full 2^32 (4GB) users address space. To take advantage of this you'll have to set the LARGEADDRESSAWARE bit in the X86 PE header file. For C# and VB.NET this means compiling with /platform:x86 and run editbin /LARGEADDRESSAWARE on the executable file

Sure. And on some versions of the 32 bit windows, you can also give 3GB virtual address space if you boot with /3GB when the LARGEADDRESSAWARE bit is set in the executable. But to me that can be just a "trick" and depending on the application may or may not be the appropriate thing to do. For a high transaction volume server apps (exchange, msmq, sql, etc), sure, being able to address that extra gig or 2 increases app performance. But if the problem is because you're trying to read an mpeg file thats 5 GB long into memory all at once, well, that's a different story and should be addressed at the design level...

Note that, despite the larger users address space available to 32 bit processes on 64 bit Windows, that the largest CLR object is still limited to ~2GB, allocating larger objects will throw OOM's even when running MSIL or X64 code on 64bit Windows.

However I've always wondered the purpose of the Array.LongLength property with respect to that limitation <g>


In the current implementation, this property is nothing else than a type cast of an int (Array.Length) to a long. Maybe we will ever see an implementation that returns what it should, that is - the *sum* of the Length of all elements
Note that the 2GB restriction is imposed by the CLR on all objects allocated on the GC heap, not only on Array types.
The Array's Length property (an Int32) denotes the number of elements in the array, without the CLR restriction, an Array could theoretically hold 16GB if the element was a long.

Willy.


.



Relevant Pages

  • Re: appending elements to an ALLOCATABLE array
    ... this feature would allow you to expand memory ... It is not a problem of allocation, ... In C this can be done using an array of pointers to dynamically ... Linked lists work very well for applications that address the data ...
    (comp.lang.fortran)
  • Re: Out of Memory Problem in VB 6.0 Application.
    ... that's a fixed size array. ... > block of memory. ... Just think of it as 2gigs of ram that you have at your disposal. ... matter if that's real ram or swap file it's still 2 gigs available to your ...
    (microsoft.public.vb.general.discussion)
  • Re: rpgle, pcml & arrays
    ... allocation. ... If the program allocates memory on demand to store the array, ... SQL provides a way for a stored procedure to return a result set. ...
    (comp.sys.ibm.as400.misc)
  • Re: How to release heap memory that is marked as free
    ... As I said, fragmentation is a very serious problem, and one of the most serious problems ... my allocator was accused of using massive amounts of memory. ... I'm going to have to re-think the memory allocation that I'm ... process's 'working set'. ...
    (microsoft.public.vc.mfc)
  • Re: [PATCH 00/28] Swap over NFS -v16
    ... memory they can consume. ... So we need the extra (skb) ... included in the reserve? ... if the allocation had to dip into emergency reserves, ...
    (Linux-Kernel)