I'm not able to allocate more than 900MB with GlobalAlloc or HeapAlloc
(VC++ 6.0, Win2K or WinXP). Even if I try to allocate 450MB twice it fails.
It seems the limit is about 850 MB even if the PC has 2GB RAM.

Re: Allocate large memory by Simon

Simon
Mon May 09 04:35:55 CDT 2005

If you try and allocate a large amount of memory in a single call, then the
system will attempt to allocate the memory as a single contiguous block. If
your process is suffering from even mild memory fragmentation, then blocks
of the size you are trying to allocate can fail.

"Montblanc" <Montblanc@discussions.microsoft.com> wrote in message
news:919E0ED9-4AD9-468C-9F0E-32EB1739B11A@microsoft.com...
> I'm not able to allocate more than 900MB with GlobalAlloc or HeapAlloc
> (VC++ 6.0, Win2K or WinXP). Even if I try to allocate 450MB twice it
fails.
> It seems the limit is about 850 MB even if the PC has 2GB RAM.



Re: Allocate large memory by Stoyan

Stoyan
Mon May 09 04:39:41 CDT 2005

MSDN: HeapAlloc[1]

"If the heap specified by the hHeap parameter is a "non-growable" heap,
dwBytes must be less than 0x7FFF8. You create a non-growable heap by calling
the HeapCreate function with a nonzero value."

This is about 500 MB. Try VirtualAlloc(Ex)

Cheers,
Stoyan

[1]
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/heapalloc.asp

"Montblanc" <Montblanc@discussions.microsoft.com> wrote in message
news:919E0ED9-4AD9-468C-9F0E-32EB1739B11A@microsoft.com...
> I'm not able to allocate more than 900MB with GlobalAlloc or HeapAlloc
> (VC++ 6.0, Win2K or WinXP). Even if I try to allocate 450MB twice it
> fails.
> It seems the limit is about 850 MB even if the PC has 2GB RAM.



Re: Allocate large memory by Jochen

Jochen
Mon May 09 04:52:28 CDT 2005

Hi Montblanc!
> I'm not able to allocate more than 900MB with GlobalAlloc or HeapAlloc
> (VC++ 6.0, Win2K or WinXP). Even if I try to allocate 450MB twice it fails.
> It seems the limit is about 850 MB even if the PC has 2GB RAM.

See also: How to get the largest available continues memory block
http://blog.kalmbachnet.de/?postid=9

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/

Re: Allocate large memory by Montblanc

Montblanc
Mon May 09 04:53:06 CDT 2005

Thank you.
But it seems that I reach the limit of memory my app can allocate. Even if
I try to allocate small blocks I'm not able to allocate more than about 900 MB
at all! I do not get a valid Handle back! As far as I know the limit is 2GB,
but
my limit seems to be about 900MB.

"Simon Watson" wrote:

> If you try and allocate a large amount of memory in a single call, then the
> system will attempt to allocate the memory as a single contiguous block. If
> your process is suffering from even mild memory fragmentation, then blocks
> of the size you are trying to allocate can fail.
>
> "Montblanc" <Montblanc@discussions.microsoft.com> wrote in message
> news:919E0ED9-4AD9-468C-9F0E-32EB1739B11A@microsoft.com...
> > I'm not able to allocate more than 900MB with GlobalAlloc or HeapAlloc
> > (VC++ 6.0, Win2K or WinXP). Even if I try to allocate 450MB twice it
> fails.
> > It seems the limit is about 850 MB even if the PC has 2GB RAM.
>
>
>

Re: Allocate large memory by Montblanc

Montblanc
Mon May 09 05:05:02 CDT 2005

Thank you.

I just tried to use VirtualAlloc, but the result is the same!

"Stoyan Damov" wrote:

> MSDN: HeapAlloc[1]
>
> "If the heap specified by the hHeap parameter is a "non-growable" heap,
> dwBytes must be less than 0x7FFF8. You create a non-growable heap by calling
> the HeapCreate function with a nonzero value."
>
> This is about 500 MB. Try VirtualAlloc(Ex)
>
> Cheers,
> Stoyan
>
> [1]
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/heapalloc.asp
>
> "Montblanc" <Montblanc@discussions.microsoft.com> wrote in message
> news:919E0ED9-4AD9-468C-9F0E-32EB1739B11A@microsoft.com...
> > I'm not able to allocate more than 900MB with GlobalAlloc or HeapAlloc
> > (VC++ 6.0, Win2K or WinXP). Even if I try to allocate 450MB twice it
> > fails.
> > It seems the limit is about 850 MB even if the PC has 2GB RAM.
>
>
>

Re: Allocate large memory by Tom

Tom
Mon May 09 05:33:27 CDT 2005

Montblanc wrote:
> I'm not able to allocate more than 900MB with GlobalAlloc or HeapAlloc
> (VC++ 6.0, Win2K or WinXP). Even if I try to allocate 450MB twice it fails.
> It seems the limit is about 850 MB even if the PC has 2GB RAM.

The problem is that to allocate memory, the OS has to find a contiguous
chunk of address space that hasn't got anything in it. If your program
has been doing any memory allocation or using any DLLs, it might well
have various bits of memory allocated throughout that address space (of
which only 2GB is available to your application in any case I think -
the rest is reserved for Windows use).

You could try reserving the space at program start up with VirtualAlloc,
and then commit it if and when you actually need it.

Tom

Re: Allocate large memory by Nemanja


Re: Allocate large memory by Ivan

Ivan
Mon May 09 10:46:14 CDT 2005

On top of what others have said about address space fragmentation,
an, as a more friendly alternative to what Jochen Kalmbach suggested,
you can try the `!address` debugger extension command in cdb/ntsd/windbg.
It will give you address space statistics and the address and size of
the largest contiguous address range.
BTW, all of this assumes there is no Job-Object limit that caps the used
address
space of your process.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Montblanc" <Montblanc@discussions.microsoft.com> wrote in message
news:919E0ED9-4AD9-468C-9F0E-32EB1739B11A@microsoft.com...
> I'm not able to allocate more than 900MB with GlobalAlloc or HeapAlloc
> (VC++ 6.0, Win2K or WinXP). Even if I try to allocate 450MB twice it
fails.
> It seems the limit is about 850 MB even if the PC has 2GB RAM.



Re: Allocate large memory by Montblanc

Montblanc
Mon May 09 11:27:44 CDT 2005

Do you think there is no limit for the Memeory to allocate?
I don't understand where to find this debugger extension!
Sorry!

"Ivan Brugiolo [MSFT]" wrote:

> On top of what others have said about address space fragmentation,
> an, as a more friendly alternative to what Jochen Kalmbach suggested,
> you can try the `!address` debugger extension command in cdb/ntsd/windbg.
> It will give you address space statistics and the address and size of
> the largest contiguous address range.
> BTW, all of this assumes there is no Job-Object limit that caps the used
> address
> space of your process.
>
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
> Use of any included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm
>
>
> "Montblanc" <Montblanc@discussions.microsoft.com> wrote in message
> news:919E0ED9-4AD9-468C-9F0E-32EB1739B11A@microsoft.com...
> > I'm not able to allocate more than 900MB with GlobalAlloc or HeapAlloc
> > (VC++ 6.0, Win2K or WinXP). Even if I try to allocate 450MB twice it
> fails.
> > It seems the limit is about 850 MB even if the PC has 2GB RAM.
>
>
>

Re: Allocate large memory by Ivan

Ivan
Mon May 09 12:22:42 CDT 2005

Each process has a technical upper limit,
given by the architecture and the OS design.
For current Windows implementations, x86 we have:
- 2Gig, x86
- 3Gig, x86 with /3G AND /LARGEADDRESSAWARE
- 4Gig, x86 under wow64 AND /LARGEADDRESSAWARE.
The upper limit, together with the runtime utilization,
leads to the limit of the largest free contiguous block of address spaces.
Then, there is the limit of the used address space,
that can be cap-ed by a job-object.

cdb/ntsd/windbg can be downloaded from
http://www.microsoft.com/whdc/devtools/debugging/installx86.mspx
After you've gotten a failure from malloc/HeapAlloc/VirtualAlloc,
issue `!address`, and check the largest region size,
so see which size would have suceeded.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Montblanc" <Montblanc@discussions.microsoft.com> wrote in message
news:BEA5589C-955B-4B15-8288-A2954219FEDE@microsoft.com...
> Do you think there is no limit for the Memeory to allocate?
> I don't understand where to find this debugger extension!
> Sorry!
>
> "Ivan Brugiolo [MSFT]" wrote:
>
> > On top of what others have said about address space fragmentation,
> > an, as a more friendly alternative to what Jochen Kalmbach suggested,
> > you can try the `!address` debugger extension command in
cdb/ntsd/windbg.
> > It will give you address space statistics and the address and size of
> > the largest contiguous address range.
> > BTW, all of this assumes there is no Job-Object limit that caps the used
> > address
> > space of your process.
> >
> > --
> > This posting is provided "AS IS" with no warranties, and confers no
rights.
> > Use of any included script samples are subject to the terms specified at
> > http://www.microsoft.com/info/cpyright.htm
> >
> >
> > "Montblanc" <Montblanc@discussions.microsoft.com> wrote in message
> > news:919E0ED9-4AD9-468C-9F0E-32EB1739B11A@microsoft.com...
> > > I'm not able to allocate more than 900MB with GlobalAlloc or HeapAlloc
> > > (VC++ 6.0, Win2K or WinXP). Even if I try to allocate 450MB twice it
> > fails.
> > > It seems the limit is about 850 MB even if the PC has 2GB RAM.
> >
> >
> >