Search code examples
memory-managementtradeoff

What constitutes a good memory profile?


In designing any desktop applications, are there any general rules on how much memory should the application uses?

For heavy-weight applications, those can be easily understood or at least profiled such as Firefox or Google Chrome. But for smaller utilities or line-of-business application, how much is an acceptable amount of memory usage?

I asked because I've recently come across a trade-off between memory usage and performance and wonder if there is any general consensus regarding it?

EDIT: Platform is Windows XP for users with machine just capable of running rich internet applications.

My specific trade-off problem is about caching a lot of images in memory. If possible, I'd love to have my app cache as much as the user's memory will allow. I have done it so that the application will cache upto a certain maximum limit considering memory pressure at the moment..

But what would be a good number? How do you come up with one? That's the point I'm asking.


Solution

  • There is no absolute answer for this. It depends on too many variables.

    Here are some trade-offs for consideration:

    • What device/platform are you developing for?
    • Do you expect your user to use this software as the main purpose for their computer (example maybe you are developing some kind of server software)
    • Who is your target audience, home users? power users?
    • Are you making realistic expectations for the amount of RAM a user will have?
    • Are you taking into consideration that the user will be using a lot of other software on that computer as well?

    Sometimes it's possible to have your cake and eat it too. For example if you were reading a file and writing it back out, you could read it chunk by chunk instead of reading the whole file into memory and then writing it out. In this case you have better memory usage, and no speed decrease.

    I would generally recommend to use more RAM to get better speed if you must. But only if the RAM requirements are realistic for your target audience. For example if you expect a home user that has 1GB of RAM to use your program, then don't use 600MB of RAM yourself.

    Consider using more RAM in this instance to get better speed, and to optimize some other part of your code to use less RAM.

    Edit:

    About your specific situation of caching images. I think it would be best for you to allow the user to set the amount of caching they would like to perform as an option. That way people with a lot of RAM can put it higher for better performance, and the people with little RAM can set it low.