Re: Keeping a file in memory
From: Allin Cottrell (cottrell_at_wfu.edu)
Date: 10/26/04
- Next message: Randy Howard: "Re: Commenting the source code."
- Previous message: Mohd Hanafiah Abdullah: "Re: C to Java Byte Code"
- In reply to: G.D.: "Keeping a file in memory"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 25 Oct 2004 22:09:11 -0400
G.D. wrote:
> I'm using a third-party library which writes some useful
> information into a file. In order to do so, I just have
> to pass a file name to a library function and the file
> gets written.
>
> The problem is that I need the information that has been
> written to the file immediately. I other words, the library
> writes the info to a file (on disk) and my code reads this
> file immediately afterwards, which makes writing the data
> on the disk a waste of time.
>
> I was wondering if there is a (ideally standardized and portable)
> way to keep a file in memory indefinitly, where it presumably
> can be read much faster?
If you want the information that is generated by the library
function _immediately_, the best solution is to have the library
write the info not to a file, but to a buffer -- a buffer to
which the clietnt program is passed a pointer. If you are not
in a position to make this modification to the library, you're
stuck with reading the file from disk.
As for "keeping a file in memory", _after_ is it read from disk,
any decent operating system will do this automagically, using
cache memory. Reading the file for the first time might be time-
consuming, if it is big file, but thereafter it will be read from
cache -- until some more pressing items fill the cache.
Allin Cottrell
- Next message: Randy Howard: "Re: Commenting the source code."
- Previous message: Mohd Hanafiah Abdullah: "Re: C to Java Byte Code"
- In reply to: G.D.: "Keeping a file in memory"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|