Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Keeping a file in memory

Reply
Thread Tools

Keeping a file in memory

 
 
G.D.
Guest
Posts: n/a
 
      10-25-2004
Hi,

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?

Any help appreciated,

G.D.
 
Reply With Quote
 
 
 
 
Artie Gold
Guest
Posts: n/a
 
      10-25-2004
G.D. wrote:
> Hi,
>
> 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?
>
> Any help appreciated,
>
> G.D.


There is not; any such facility, if it exists, would be platform specific.

HTH,
--ag

--
Artie Gold -- Austin, Texas

"If you don't think it matters, you're not paying attention."
 
Reply With Quote
 
 
 
 
Allin Cottrell
Guest
Posts: n/a
 
      10-26-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Keeping datatable data in memory =?Utf-8?B?SnVsaWEgQg==?= ASP .Net 5 10-31-2007 08:57 AM
perl is keeping my memory peter pilsl Perl Misc 4 05-17-2006 10:33 AM
Book-keeping metadata for allocated memory pinkfloydhomer@gmail.com C Programming 15 03-27-2006 04:07 AM
Keeping A "Persistent" XML Document In Memory DartmanX Javascript 2 10-12-2005 09:50 PM
keeping Mozilla in memory wc Firefox 3 08-01-2004 07:42 PM



Advertisments