64位内存分配 [英] 64bit Memory allocation

查看:114
本文介绍了64位内存分配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被要求在C ++中创建一个Delphi兼容的dll来做简单的64位内存管理。

I've been asked to create a Delphi compatible dll in C++ to do simple 64bit memory management.

后台是Delphi中的系统需要分配大量的内存块,会在32位可寻址空间之外。 Delphi开发人员向我解释说,他不能用他可用的Delphi命令分配内存。他说他可以持有一个64位的地址,所以他只是想调用我提供的一个函数来分配内存并返回一个64位的指针给他。

The background is that the system in Delphi needs to allocate a lots of chunks of memory that would go well outside 32bit addressable space. The Delphi developer explained to me that he could not allocate memory with the Delphi commands available to him. He says that he can hold a 64bit address, so he just wants to call a function I provide to allocate the memory and return a 64bit pointer to him. Then another function to free up the memory later.

现在,我只有VS 2008在我的处置,所以首先,我甚至不知道我可以创建一个Delphi兼容的dll

Now, I only have VS 2008 at my disposal so firstly I'm not even sure I can create a Delphi compatible dll in the first place.

任何Delphi专家都在帮助我。也许有一种方式来实现他所需要的,而不需要重新发明的轮子。

Any Delphi experts care to help me out. Maybe there is a way to achieve what he requires without re-inventing the wheel. Other developers must have come across this before in Delphi.

所有评论赞赏。

推荐答案

只有64位进程可以寻址64位内存。 64位进程只能加载64位dll,32位进程只能加载32位dll。 Delphi的编译器只能生成32位二进制文​​件。

Only 64 bit processes can address 64 bit memory. A 64 bit process can only load 64 bit dlls and 32 bits processes can only load 32 bits dlls. Delphi's compiler can only make 32 bits binaries.

所以一个32位的Delphi exe不能加载你64位的c ++ dll。它可以加载一个32位的c ++ dll,但然后该dll将无法解决64位内存空间。您可能会遇到这种解决方案。

So a 32 bits Delphi exe can not load your 64 bit c++ dll. It could load a 32 bit c++ dll, but then that dll wouldn't be able to address the 64 bit memory space. You are kind of stuck with this solution.

Delphi可以通过合适的编译器选项和Windows开关解决3GB的内存问题。如果使用物理地址扩展,则可以通过32位进程访问更多内存。然后,它需要通过使用地址窗口扩展将内存页交换进32位内存。

Delphi could, with the right compiler options and Windows switches address 3GB of memory without problems. Even more memory could be accessed by a 32 bits process if it uses Physical Address Extension. It then needs to swap memory pages in and out of the 32 bits memory through the use of Address Windowing Extensions.

这篇关于64位内存分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆