 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Florent Ouchet Guest
|
Posted: Tue May 10, 2005 5:20 pm Post subject: MM: What should be the maximum allocated size ? |
|
|
Hi,
What should be the maximum size that could be allocated at a time ?
Is it possible to get more than 2GB (2^31 Byte) in one call ? Can the
Microsoft's VirtualAlloc or HeapAlloc allocate this size ?
If it is not possible, it should be possible to use the last bit as a
free flag; and use the 31 lower bits to store the size.
TIA,
Florent
|
|
| Back to top |
|
 |
Eric Grange Guest
|
Posted: Tue May 10, 2005 6:18 pm Post subject: Re: MM: What should be the maximum allocated size ? |
|
|
| Quote: | Is it possible to get more than 2GB (2^31 Byte) in one call ?
|
Not in 32 bit. It may theoretically be possible with the /3GB switch,
but in practice there will always be some memory allocated in the middle
of the virtual memory space, which means the largest contiguous block of
free memory is much smaller.
When you have 1 GB of contiguous space (and can allocate a 1 GB block),
you should already consider yourself very lucky.
Eric
|
|
| Back to top |
|
 |
Avatar Zondertau Guest
|
Posted: Tue May 10, 2005 6:48 pm Post subject: Re: MM: What should be the maximum allocated size ? |
|
|
| Quote: | Is it possible to get more than 2GB (2^31 Byte) in one call ?
Not in 32 bit. It may theoretically be possible with the /3GB switch,
but in practice there will always be some memory allocated in the
middle of the virtual memory space, which means the largest
contiguous block of free memory is much smaller. When you have 1 GB
of contiguous space (and can allocate a 1 GB block), you should
already consider yourself very lucky.
|
This is really easy to test. Though results may vary slightly this will
give an indication:
function FindMaxAllocSize: LongWord;
var
Avg, Max, Min: LongWord;
Mem: Pointer;
begin
Min := $00000000;
Max := $80000000;
while Min < Max do
begin
Avg := (Min + Max + 1) div 2;
Mem := VirtualAlloc(nil, Avg, MEM_RESERVE, PAGE_NOACCESS);
if Mem = nil then
Max := Avg - 1
else
begin
VirtualFree(Mem, 0, MEM_RELEASE);
Min := Avg;
end;
end;
Result := Min;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage('You can allocate 0x' + IntToHex(FindMaxAllocSize, +
' bytes');
end;
My result:
You can allocate 0x45160000 bytes
This is more that 1.1 GB.
|
|
| Back to top |
|
 |
Florent Ouchet Guest
|
Posted: Tue May 10, 2005 6:58 pm Post subject: Re: MM: What should be the maximum allocated size ? |
|
|
| Quote: | You can allocate 0x45160000 bytes
This is more that 1.1 GB.
|
The limit on my computer is $3F330000 (1060306944 Bytes). (Windows 2000
Pro SP4, 512MB RAM, 512MB Swap).
It may be interesting if you tell us your physical and virtual memory sizes.
TIA,
Florent
|
|
| Back to top |
|
 |
Florent Ouchet Guest
|
Posted: Tue May 10, 2005 7:05 pm Post subject: Re: MM: What should be the maximum allocated size ? |
|
|
| Quote: | The limit on my computer is $3F330000 (1060306944 Bytes). (Windows 2000
Pro SP4, 512MB RAM, 512MB Swap).
|
Really interesting, I just opened my eyes and saw that it is possible to
reserve more memory than available (Windows, Mozilla and Delphi should
use more than 100Mb)...
Florent
|
|
| Back to top |
|
 |
Avatar Zondertau Guest
|
Posted: Tue May 10, 2005 7:19 pm Post subject: Re: MM: What should be the maximum allocated size ? |
|
|
| Quote: | The limit on my computer is $3F330000 (1060306944 Bytes). (Windows
2000 Pro SP4, 512MB RAM, 512MB Swap).
|
Windows XP Pro, 512 MB RAM, swap file 765 MB.
| Quote: | Really interesting, I just opened my eyes and saw that it is possible
to reserve more memory than available (Windows, Mozilla and Delphi
should use more than 100Mb)...
|
The memory is only being reserved, not commited. You should try and see
what happens if you change that parameter to make it commit.
I guess you'll be getting a "Windows is running low on memory, please
close programs or increase swap size" message. The reservation is seems
to be mostly used for keeping the virtual address space free, not for
making sure the memory is actually available.
|
|
| Back to top |
|
 |
Avatar Zondertau Guest
|
Posted: Tue May 10, 2005 7:21 pm Post subject: Re: MM: What should be the maximum allocated size ? |
|
|
| Quote: | Really interesting, I just opened my eyes and saw that it is
possible to reserve more memory than available (Windows, Mozilla
and Delphi should use more than 100Mb)...
The memory is only being reserved, not commited. You should try and
see what happens if you change that parameter to make it commit.
|
It turns out for me the maximum commit size equals the maximum reserve
size. Would it perhaps only really commit on the first write?
|
|
| Back to top |
|
 |
Eric Grange Guest
|
Posted: Wed May 11, 2005 7:58 am Post subject: Re: MM: What should be the maximum allocated size ? |
|
|
| Quote: | Would it perhaps only really commit on the first write?
|
On the first access to a page (read or write) it will start using "real"
memory (either RAM or SWAP) for that page.
Eric
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|