如何申请操作系统的物理内存?

lance_123 2009-06-23 04:59:07
一般我们在应用程序中用new,malloc函数,都是申请虚拟内存。
我想直接能够申请物理内存。
查看了一些资料,有人说用AllocateUserPhysicalPages这个函数,但是我在VC6下怎么也运行不起来了。换了在VS2005下也不行。。。
请问有人写过这样的程序吗?帮助解决一下。谢谢。
...全文
111 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lance_123 2009-06-23
  • 打赏
  • 举报
回复
看过了,因为打算开发一个数据库产品。而这样需要对内存有很好的管理。第一步就是想把数据全部放在物理内存上去处理,而不需要让操作系统去置换。从而降低性能。
biweilun 2009-06-23
  • 打赏
  • 举报
回复
我觉得好奇怪,干吗非要物理内存不可呢。

实在要,请看这个牛帖:http://bbs.et8.net/bbs/archive/index.php/t-488600.html
lance_123 2009-06-23
  • 打赏
  • 举报
回复
#define _WIN32_WINNT 0x0500
也试过了,就是不行。
lance_123 2009-06-23
  • 打赏
  • 举报
回复
加了#define _WIN32_WINNT 0x0501
这个也不行。。。
环境是VC6
: error C2065: 'AllocateUserPhysicalPages' : undeclared identifier
报这个错误。。
oyljerry 2009-06-23
  • 打赏
  • 举报
回复
http://msdn.microsoft.com/en-us/library/aa366528(VS.85).aspx

The AllocateUserPhysicalPages function is used to allocate physical memory that can later be mapped within the virtual address space of the process. The SeLockMemoryPrivilege privilege must be enabled in the caller's token or the function will fail with ERROR_PRIVILEGE_NOT_HELD. For more information, see Privilege Constants.

Memory allocated by this function must be physically present in the system. After the memory is allocated, it is locked down and unavailable to the rest of the virtual memory management system.

Physical pages cannot be simultaneously mapped at more than one virtual address.

Physical pages can reside at any physical address. You should make no assumptions about the contiguity of the physical pages.

To compile an application that uses this function, define the _WIN32_WINNT macro as 0x0500 or later. For more information, see Using the Windows Headers.

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧