English 中文(简体)
What should I load into memory when my app loads?
原标题:

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?

问题回答

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.

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

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.

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.

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.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签