In Borland's Documentation, routine GetMem() implements VirtualAlloc()
internally. But I write a demo and find GetMem only allocate 500M memory and
VirtualAlloc can allocate upper 1G memory in my 256M physical memory PC.
Anyone can try to access a Big file(size > your physical memory) with
GetMem() and see result.
My question is :
(1),Do GetMem() implement Virtual Memory Management internally? Need I
use VritualAlloc() straight?
(2), If (1) is No, so how can I implement Virtual Memory Management? Use
VirtualAlloc() or select a right Memory Manager in Delphi?
Thanks!
Michael Lv
For both functions a limit is 2GB. This is because in win32 enviroment,
all applications can allocate up to 2GB of memory (exactly 2^31 or 2^31 -
1). This, of course, is a virtual limit, whereas physical limit is the sum
of physical RAM and page file size.
Tomaz
"Michael Lv" <leisu...@263.net> wrote in message
news:3dec42c4$1...@newsgroups.borland.com...
> No, so how can I implement Virtual Memory Management? Use
> VirtualAlloc() or select a right Memory Manager in Delphi?
You might also want to check out the HeapAlloc() Win32 API.
--
"Only choice is an oxymoron."
MyObj := TMyObj.Create;
Can you tell me MyObj use heap memory or virtual memory?
Michael Lv
Michael, I think that nearly all of a Windows' applications memory
can be swapped out to the disk swap area. I am guessing that that
is what you mean by virtual. I believe that there is a way to limit
such swapping, but I have never used it. Why were you asking?
Regards, JohnH
Yes, MS use swapping files to implement virtual memory
management(right?). At past, I think GetMem() encapsulate internal virtual
memory management mechanism, so I use GetMem() function to access a 500M
file in my PC with only 256M physical memory. GetMem() can only allocate
about 400M memory for process and Windows raise "Out of Memory" exception.
I use VirtualAlloc() API to access file directly and make things better,
which can get upper 1G virtual memory. But I can't resolve such
memory-allocating like "TObject.Create", which be controlled by Delphi's
internal memory allocation mechanism. So my question is :
1, Can we believe GetMem() function for virtual memory allocation?
2, How can I manipulate memory allocation like "TObject.Create"?
Thanks!
Hi Michael,
Not sure about No. 1, but with No.2 you can declare your own class and
override the NewInstance method. NewInstance is responsible for
allocating an object's memory.
Regards,
Scott