3 ms·
This article is way inaccurate. It recommends approaches that were maybe important in 1997. It also breaks the "profile before optimising" rule. Currently the
by stevoski 13y ago
This article is way inaccurate. It recommends approaches that were maybe important in 1997. It also breaks the "profile before optimising" rule.
Currently the Java GC works splendidly with lots of short-lived, small immutable classes. Using this approach can be far better for performance than worrying about telling the ArrayList constructor how many elements the list will probably have.
- SpikeGronim 13y agoAbsolutely. Step 0 of this article should have been "profile your GC and establish that it is a problem."
- saurik 13y agoWhile VMs like Sun's may be using techniques like escape analysis, I seriously doubt that Dalvik does (it seems like dx might, but that's going to be of limited value at compile time, and it isn't clear how it uses the information): a lot of people these days coding in Java are doing so for Android, where the garbage collector is a serious problem, sufficiently so that all garbage collections are logged to the system log (so as a developer you don't even need to go to much work to profile it as an issue: you just see the pain in your console and then likely seem out this article).