提交和锁定虚拟内存有什么区别? [英] What is the difference between committing and locking virtual memory?

查看:227
本文介绍了提交和锁定虚拟内存有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一些C函数.

例如; VirtualAlloc()保留并提交,并且VirtualLock()锁定虚拟内存空间的区域.

For example; VirtualAlloc() reserves and commits and VirtualLock() lockes a region of the virtual memory space.

它们之间有什么区别?

推荐答案

VirtualLock锁定进程虚拟的指定区域 将空间寻址到物理内存中,确保随后对 该区域不会发生页面错误.

VirtualLock locks the specified region of the process's virtual address space into physical memory, ensuring that subsequent access to the region will not incur a page fault.

VirtualAlloc向内核请求内存-即在分配后,您将获得新的内存块来使用.内核通常需要换出内存以为其他内容腾出空间. VirtualLock要求内核不要换出内存区域.

VirtualAlloc requests memory from the kernel - i.e. after the allocation you get a new chunk of memory to play with. The kernel often needs to swap out memory to make room for other stuff. VirtualLock asks the kernel not to swap out a region of memory.

这篇关于提交和锁定虚拟内存有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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