Ever decreasing cost of main memory
I have blogged about the relative cost of memory to the cost of your time. Memory in servers is so cheap that for small amounts of memory, it just isn't worth your time to introduce complexity into your application to try to save it. The average salary for a developer in the UK is £40,000 and the average cost of memory is £5 per GB. The cost to your organisation for both is higher and if you have many machines saving a 1 MB on 1000 machines saves 1 GB, however memory is so divisible you can quickly run into small amounts of memory which are not worth your time saving. Hard disk space is even cheaper and most people get its not worth keeping your disks completely clean all the time, because the cost of deleting a file you later need is high, but also the value of the space you save is not worth your time. A typical 2 TB of mirrored disk in a network appliance costs about £300.
For self learning, interest or fun you might think about ways of saving small amounts of memory or disk. But for work, the most efficient way to program may be to save your time and those who have to maintain your code, and waste some hardware resources in the process. BTW: hardware resources are more re-usable than your time.
|Main memory to save in total
|Disk space to save
|Blink of an eye (20 ms)
|One line of tested code (2 mins)
|A small sized well tested
library, 100 lines (0.5 days)
|A medium sized well tested,
documented library, 1000 lines (1 week)