Timeline for Should we avoid object creation in Java?
Current License: CC BY-SA 3.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 3, 2018 at 16:32 | comment | added | Bill K | The first and last points don't apply to small objects that are quickly released, they die in eden (think stack allocation in C, pretty much free) and never effect GC times or memory allocation. Most object allocation in Java falls into this category and is therefore essentially free. The second point is still valid. | |
| Jan 25, 2015 at 8:51 | comment | added | Jules | Also, 100% correct escape analysis is equivalent to the halting problem. Don't rely on escape analysis in complex situations, as it is likely to give the wrong answer at least some of the time. | |
| Jun 27, 2013 at 11:43 | comment | added | mikera | @Richard: great point - escape analysis provides some very good optimisations. You have to be careful about relying on it though: it isn't guaranteed to happen in all Java implementations and in all circumstances. So you often need to benchmark to be sure. | |
| Jun 27, 2013 at 10:36 | comment | added | Richard Tingle | Its worth noting that escape analysis will allow short lived (bounded life) objects to be stored on the stack, these objects can be deallocated for free ibm.com/developerworks/java/library/j-jtp09275/index.html | |
| May 22, 2012 at 11:32 | history | edited | mikera | CC BY-SA 3.0 | added 31 characters in body |
| May 22, 2012 at 11:17 | history | answered | mikera | CC BY-SA 3.0 |