如何将文件保存在内存中 [英] how to keep files in memory

查看:332
本文介绍了如何将文件保存在内存中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想编写一个程序来做到这一点:

将一些文件保留在内存中,以便当另一个程序要读取该文件时,应从内存而不是从磁盘加载.

Hi,
I want to write a program to do this:

keep some files in memory,such that when another program want to read the file,he should load from memory rather than from disk.

how can i do this?

推荐答案

您不能这样做,Windows文件缓存效果很好.
否则,您可以使用FileMapping对象在不同进程之间共享内存.
(我假设您使用Windows)
问候.
You must not do that, the windows file cache works very well.
Otherwise you can use FileMapping objects to share memory among different processes.
(i assumed youre using windows)
Regards.


只需创建一个客户端/服务器应用程序

或可能是简单的RPC应用程序

或IPC应用程序.

它们中的任何一个都会切断您的目的
Just Create a client/server application

or may be simple RPC application

Or IPC application.

Any of them will sever your purpose


您不能使用Windows或任何其他OS(例如Linux或MAC)来执行此操作.原因是,由于Windows与各种安全功能一起在保护模式下运行,当某个程序将某些文件加载​​到某个特定内存块中的RAM中时,该内存块只能由该程序本身访问.因此,没有其他程序可以访问该内存位置.

希望!以上单词回答了您的问题...:)
You can not do this using Windows or any other OS like Linux or MAC. The reason is that, As Windows runs in Protected Mode along with various security features, when some file is loaded by some program in to the RAM in some particular memory block, that memory block is restricted to access by that program itself. Hence, No other programs can access that memory location.

Hope! the above words have answered you question... :)


这篇关于如何将文件保存在内存中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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