This has always been on my mind while programming, so I thought I’d spit it out before it actually gets to me.
What should i be more worried about? The memory the application consumes, or the performance it takes. By this I mean should I be focused upon using less memory for of the application and using more performance (eg. loading via database, and dumping it after use), or using less performance and using more memory (eg. caching)
My conditions for the application:
– It’s a server application, so it’s not meant to be ran on desktops, etc, I have 6GB of ram, and I have a quad-core.
Your question has drawn a lot of Zen Buddhism-like responses. I hope to do better.
Your memory limit is hard: If you exceed it, even if there’s virtual memory, your app will crawl and you’ll be the laughing stock of all.
Your CPU time is unlimited: Your app will take whatever time it needs; hopefully it will be sufficiently parallel that all 4 CPUs will be, for the most part, cooking with full steam until your app is finished.
Many Computer Science problems have a variety of solutions with various tradeoffs of memory against time. So: Be generous with memory until you use at least about half of it (if that helps; don’t waste memory for the heck of it!) but stop while there’s enough memory left that you don’t need to worry about exceeding the limit, even in exceptional cases or accidentally.
Now that you’ve allocated your memory resources, you can try to tweak some more small performance gains out of your code. But don’t bother overdoing it.
Done.
P.S. If it doesn’t work correctly and reliably, all the preceding effort is worthless. Keep that in mind all the time!
Good luck.