How to write a memory manager that displays 4 GB for Delphi

I have an object that uses more than 2 gigabytes of virtual memory. But Delphi is only 2 GB managers. I consider the ether, making a number of objects and grouping them, and using the wow64 Windows method, how and how to use 64-bit windows. Or just upgrade your memory manager to 4 GB and create it around Int64. effectively I need a TStream as a base object using Int64 instead of integers.

+4
source share
4 answers

Lexdean, you say:

I need a TStream as a base object using Int64 instead of integers

Well, then you were lucky (twice) because:

  • Delphi TStream uses Int64 for position, it can access files much more than 4Gb.
  • If the TStream interface is enough, you can write your own TStream to do whatever you want, you do not need to wait for your own 64-bit Delphi compiler.

But if I have to answer the question in the title:

How to write a memory manager that displays 4 gigabytes for Delphi

There is no way to do this with a 32-bit compiler. Join the crowd of people asking for a 64-bit Delphi compiler!

+14
source

Having one 2 gigabyte object is not a good idea. If the memory is fragmented, you cannot allocate it, even if there is enough free memory. I would suggest that you are trying to use a list of smaller objects.

(I remember how in Turbo Pascal (Delphi's predecessor) a variable could not be more than 64 kilobytes ... Oh, times ...;)

+5
source

Unfortunately, the Delphi compiler does not yet compile 64-bit code. However, you can get more out of your 32-bit address space if you put {$SetPeFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} in DPR. It sets a flag in the PE header, which lets Windows know that it can allocate more than 2 GB of virtual memory for it.

Guffa is right. If your object is trying to capture 2GB + of continuous memory, you are probably doing something wrong. What are you trying to do? Maybe there is an easier way ...

+4
source

You can use the AWE API to access more memory in win32 applications. But you should think that your code is around AWE instead of adapting AWE to your code. I mean, you can write TAWEMemoryStream ... but this is not a good idea.

+2
source

Source: https://habr.com/ru/post/1314902/


All Articles