应用程序管理自己的虚拟内存 [英] Application to manage its own Virtual Memory

查看:144
本文介绍了应用程序管理自己的虚拟内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对虚拟内存有些怀疑.

I have a slight doubt regarding virtual memory.

通常,操作系统要提供虚拟内存来使用磁盘空间来扩展似乎可用于应用程序的内存量.

Normally, it is up to the OS to provide virtual memory to using disk space to expand the amount of memory which appears to be available for applications.

操作系统将通过将数据复制到磁盘并在需要时进行还原来清除物理内存.

The OS will clear physical memory by copying the data to disk and restoring when needed.

但是,应用程序有可能管理自己的虚拟内存"而不是操作系统,例如,通过将对象写入文件然后销毁它们?

However, it is possible for an application to manage its own "virtual memory" rather than the OS, for example by writing objects to a file then destroying them?

如果是这样,是允许应用程序管理自己的虚拟内存以获取优势还是允许OS提供?

If so, is allowing application to manage its own virtual memory for advantageous or allowing the OS to provide?

推荐答案

大多数应用程序甚至无法知道它们是使用虚拟内存进行管理的,因为操作系统将对您的应用程序发出的每个内存请求执行地址转换

Most applications would not be able to even know that they are being managed using virtual memory because the operating system would perform address translation on every memory request made by your application.

除非您在非常低级的环境中工作(在这种情况下,您可能仍在编写自己的操作系统),否则这绝对是操作系统的最佳任务.

This is a task definitely best left to the operating system unless you are working in a very low-level environment (in which case you are probably writing your own operating system anyway).

除了需要内核特权才能完成这一事实之外,您还需要注意不要破坏其他进程的内存.

Aside from the fact that this requires kernel privileges to accomplish, you would need to take care not to corrupt other process' memory.

操作系统是这种逻辑的最佳选择.

The operating system is the best place for this kind of logic.

这篇关于应用程序管理自己的虚拟内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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