I have an object that uses more than 2 gigs if virtual memory But Delphi only managers 2 Gigs I'm considering ether making a number of objects and grouping them and using the windows wow64 method some how and use 64 bit windows. Or just upgrading memory manger to 4 gigs and build it around Int64. effectively I need TStream as the base object with Int64 used, instead of integers.
Having a single 2 gigabyte object is not a good idea. If memory is fragmented you won't be able to allocate one even if the amount of free memory is enough. I would suggest that you try to use a list of smaller objects.
(I remember how in Turbo Pascal (the predecessor to Delphi) a variable couldn't be larger than 64 kilobyte... Oh, the times... ;)
Unfortunately there's no Delphi compiler as of yet that compiles 64-bit code. You can get more out of your 32-bit address space if you put {$SetPeFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
in the DPR, though. It sets a flag in the PE header that lets Windows know it can allocate more than 2 GB of virtual memory to it.
Guffa's right, though. If your object is trying to grab 2GB+ of contiguous memory, you're probably doing something wrong. What are you trying to do? Maybe there's a simpler way...
Lexdean, you're saying:
effectively I need TStream as the base object with Int64 used, instead of integers
Well then, you're in luck (twice) because:
- Delphi's TStream uses Int64 for position, it can access files much larger then 4Gb.
- If a TStream interface is enough, you can write your own TStream to do whatever you want, you don't need to wait for an native 64bit Delphi compiler.
But if I were to answer the question in the title:
How to write a memory manager that maps 4 giggs for Delphi
There's no way to do that with an 32bit compiler. Join the crowd of people asking for an 64 bit Delphi compiler!
You can use AWE APIs to obtain access to more memory in win32 apps. But you have to think your code around AWE rather than adapt AWE usage for your code. What I mean is that you can write a TAWEMemoryStream ... but it is not a good idea.
fragmented memory is a big issue true The calls to use memory by Delphi has not been understood well The WOW64 needs better understanding yet Under Delphi I have made 200 MB stream but only 64000 memory blocks can be called
O found alex very help full If I call a process I get a 32 bit memory pay if the computer has the vertaul memory that I can bulit 65,000 times in the process its just getting access into the process that i have to achive. This is what protected memory is about.
Lex Dean