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

查看:310
本文介绍了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位进程访问更多内存。然后,需要通过使用地址窗口扩展

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天全站免登陆