Click here to Skip to main content
15,907,281 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
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?
Posted
Updated 14-Aug-11 5:41am
v2
Comments
Richard MacCutchan 14-Aug-11 13:41pm    
The chances are that even if you could do this, the actual file data would end up in virtual memory and be paged out to disk so you would still be reading from a disk somewhere. This would serve little purpose and would most likely tie up system resources and make your system run slow.
Sergey Alexandrovich Kryukov 15-Aug-11 0:00am    
Very good point. Also, as mbue correctly pointed out, file cache works well.
Overall, any attempts to do what OP wants would typically make things worse compared to reading files in the standard ways.
--SA

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.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 15-Aug-11 0:01am    
Agree, my 5.
--SA
Just Create a client/server application

or may be simple RPC application

Or IPC application.

Any of them will sever your purpose
 
Share this answer
 
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... :)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900