Igor
Tue Sep 28 16:25:20 CDT 2004
"Lynn McGuire" <NOSPAM.winsim@NOSPAM.winsim.com> wrote in message
news:%23K9$G0YpEHA.1960@TK2MSFTNGP10.phx.gbl
>>> Is there a way to force the malloc in VC++ 2003 to use addresses
>>> above 0x12000000 for virtual memory ?
>
>> But why not use VirtualAlloc?
>>
>> See: VirtualAlloc
>>
http://msdn.microsoft.com/library/en-us/memory/base/virtualalloc.asp
>
> Hmmm. It works for the first time. But the 2nd time I call it for
> another memory chunk, it gives me the same memory address !
> Something here
> is not clear !
You are perhaps confused by the fact that VirtualAlloc allocates memory
in chunks the size of system allocation granularity (see GetSystemInfo,
SYSTEM_INFO::dwAllocationGranularity), which is 64K on most (all?)
architectures running Win32. If you call VirtualAlloc with a hint
(non-NULL lpAddress parameter), it will round this pointer down to the
nearest 64K boundary.
--
With best wishes,
Igor Tandetnik
"On two occasions, I have been asked [by members of Parliament], 'Pray,
Mr. Babbage, if you put into the machine wrong figures, will the right
answers come out?' I am not able to rightly apprehend the kind of
confusion of ideas that could provoke such a question." -- Charles
Babbage