Wasting time by saving memory

You might say that at my company, the hard ware is 10x more expensive, but it also likely you time is costing the company about the same more.

In any case, this article attempts to demonstate that there is a tipping point where it no longer makes sense to spend time saving memory, or even thinking about it.
 
 
 
 
 
 
 

time
spent
cheap
memory
expensive
memory
cheap
disk
expensive
disk
a screen refresh
20 ms
      27 KB150 bytes       1 MB  24 KB
one trivial change
~1 sec
     1.4 MB  7.6 KB     60 MB    1.2 MB
one command
~5 sec
        7 MB  50 KB   400 MB    6 MB
a line of code
~1 min
      84 MB 460 KB  3,600 MB  72 MB
a small change
~20 min
  1600 MB    9 MB72,000 MB    1.4 GB
a significant change
~1 day
       40 GB  0.2 GB  1,700 GB  35 GB
a major change
~2 weeks
      390 GB  2 GB17,000 GB 340 GB

 
Your mileage may vary, but just today some one asked how to save a few bytes by passing short instead of int as method arguments (Java doesn’t save any memory if you do) Even if it did save as much as it might, the time taken to ask the question, let alone implement and test it, could have been worth 10,000,000 times the cost of memory it could have saved.

In short; don’t fall into the trap of a mind boggling imbalance of scale.
 

Reference: Wasting time by saving memory from our JCG partner Peter Lawrey at the Vanilla Java blog.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

JPA Mini Book

Learn how to leverage the power of JPA in order to create robust and flexible Java applications. With this Mini Book, you will get introduced to JPA and smoothly transition to more advanced concepts.

JVM Troubleshooting Guide

The Java virtual machine is really the foundation of any Java EE platform. Learn how to master it with this advanced guide!

Given email address is already subscribed, thank you!
Oops. Something went wrong. Please try again later.
Please provide a valid email address.
Thank you, your sign-up request was successful! Please check your e-mail inbox.
Please complete the CAPTCHA.
Please fill in the required fields.

2 Responses to "Wasting time by saving memory"

  1. An0nym0usC0ward says:

    It all depends. If you absolutely need to run your code on a mem-constrained machine, or your code will run in ten million instances (for example being run on ten million mobile phones), spending a day to save a kilobyte might be time well spent.

  2. Tom W says:

    Yes, it’s amazing how people (even in the software industry) waste time worrying about bytes, on big systems perfectly able to handle the data.

    I’ve seen such focus on the trivial add tens of thousands of dollars in costs, and get designs wrong. Normally for decent-sized hardware the metric should be “cost of integration” & “cost of future adaptability/ maintenance”, low-level metrics emphasize the wrong design goals.

Leave a Reply


one + = 4



Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy | Contact
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below:
Close