The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: gofab on August 15, 2006, 04:08:22 PM

Title: Maximum memory
Post by: gofab on August 15, 2006, 04:08:22 PM
Hi to everybody,
I just would want to know how much is the maximum dimension for an array in Masm32, is it possible to declare an array of 500 Mega byte??
(I know I can theoretically address 4Gbyte, so I assume I can use them like I want....)

Thank you in advance,
Fabrizio
Title: Re: Maximum memory
Post by: hutch-- on August 15, 2006, 04:11:49 PM
Fabrizio,

It is dictated by the OS, not the language but if you have enough memory you can allocate up to 2 gig using the system API calls. MASM handles these fine. I sometimes test procedures on 1 gig VOB files loaded directly into memory so it no big deal to do if the machine has enough memory.
Title: Re: Maximum memory
Post by: gofab on August 15, 2006, 06:45:03 PM
Hutch,

Thank you for the replay, I'll go to MSDN to see which API function I can use  :boohoo:

Best regards, Fabrizio
Title: Re: Maximum memory
Post by: Tedd on August 16, 2006, 09:03:10 AM
Sometimes when people refer to 'arrays' they mean for it to be allocated as a local variable. (Not that I'm saying you are, but just in case :wink)
'Allocating' large variables on the stack is not usually a good idea. In your case, using GlobalAlloc or HeapAlloc is fine for blocks of memory well over 500MB :U
(Though in certain cases HeapAlloc is limited to just under 512MB.. so maybe GlobalAlloc is preferable.)
Title: Re: Maximum memory
Post by: gofab on August 18, 2006, 08:43:49 PM
Thank you Tedd,

I can save much time with your suggestions, now I must just have to test the suggestions, I will inform you about the result  ::)
Title: Re: Maximum memory
Post by: u on August 19, 2006, 10:00:45 PM
For large arrays, it's best to use VirtualAlloc. Will work well on every Win OS.