Re: Storing data in memory vs reading data from a file

From: Chris Tacke, eMVP (ctacke[at]Open_NET_CF[dot]org)
Date: 05/12/04


Date: Wed, 12 May 2004 06:00:57 -0400

Since CE files are typically in RAM, file access speed is pretty fast. I'd
opt to load only the data needed, but in the end performance is a subjective
criteria and only you (and your users) can decide what's acceptable.

-Chris

"bloggs" <anonymous@discussions.microsoft.com> wrote in message
news:35BD81CC-5A05-4302-9720-B011FF9CA0A8@microsoft.com...
> Hello Forum,
>
> I have a question in regards to the most appropriate way to handle large
amounts of data stored on in a file. I am writing an application that
displays data about objects (e.g. cars). The information about each car is
stored in one text file. The text file can store information about multiple
cars but the application only displays information about one car at a time.
To view information about another car, the user taps a button (up/down
arrow) and information about the next car in the file is displayed.
>
> My question is, in terms of access speed and limiting the amount of memory
used, does it make more sense to read the entire file when the application
starts and store it in memory or read data from the file as the user
requests information about each car?
>
> I figure, by storing all the information in memory, it is quickly
accessable as there is no need to load the data into memory when it is
required. However, this approach may require a lot ot memory. On the other
hand, reading and storing information about one car at a time reduces the
amount of memory required. However, the time to load the information
increases as you have to access the file for each car.
>
> Any suggestions on which would be the better option would be greatly
appreciated. If you can suggest an alternative approach, I would like to
hear it.
>
> Cheers,
> Joe