tags:

views:

71

answers:

5

I have objects I am saving to the file system using serialization. When I load the app, should I load all the objects into memory or just stubs (for searching capabilities)?

If I load just stubs, then I would load them from the file system when they are needed and keep them in memory after that for quick access.

The order of magnitude is hundreds of records not thousands.

Which way would you recommend?

A: 

If the size and number of objects will always be rather small, load them at startup. Use stubs/proxies otherwise.

EricSchaefer
A: 

It depends.

If you know it will never exceed hundreds, then pop them all into memory.

If there's a small chance you're underestimating the total, use stubs.

It also depends on the size of the records and how often they change.

Randolph Potter
+4  A: 

Load as required, and the keep in memory, dont waste starup time loading things that will not be used.

You might even try to keep a records of most requested items, and load those then on startup.

astander
+1. Being stuck maintaining an application that loads everything up-front, I could not agree more. There is no reason to have to add time after compilation before you can actually begin execution. It makes those "quick fixes" anything but quick.
joseph.ferris
Nothing worse than waiting for an app to load "static" data if it is not used X-)
astander
A: 

It would really depend on your usage scenarios for those objects. Are they all used frequently by the application when it is running? Are they used infrequently? Are some used frequently while others are used infrequently?

Also, what is the expected resource baseline of the systems your application will be running on? Are the objects you are loading large or small? Even if there are only a few hundred of them, if they are all very large objects, that would be a significant factor. If you need a low profile application, then loading on demand would seem more logical.

This kind of question is difficult to answer without knowing more about the expected usage and baseline execution environment. Its very subjective.

jrista
A: 

Memory vs Performance. Choose which one is more important (or rather, how important each is) and adjust your caching of objects accordingly.

You could even use the Enterprise Library Caching Block, which could speed your implementation.

Gregory