tags:

views:

230

answers:

6

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.

+3  A: 

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... ;)

Guffa
+4  A: 

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...

Mason Wheeler
IMAGE_FILE_LARGE_ADDRESS_AWARE requires also the /3GB Windows switch on 32 bit machines, or a 64 bit operating system.
ldsandon
He already said that he'is using x64.
Alexander
alex has the answerwe have to investergte and not just think limitions/rules/law Lex Dean
lexdean
+12  A: 

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:

  1. Delphi's TStream uses Int64 for position, it can access files much larger then 4Gb.
  2. 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!

Cosmin Prund
http://delphi.uservoice.com/forums/4432-general/suggestions/143779-64-bit-support ;)
Alexander
Now I think that x64 compiler isn't that great idea: now people would start allocating 4-6 Gbs of memory, without thinking about trying different approach... :D
Alexander
+3  A: 

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.

alex
Thanks alex you have the answer I need so badThats the oneThanks a lotLex Dean
lexdean
A: 

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

lexdean
A: 

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

lexdean