Timeline for Should we avoid object creation in Java?
Current License: CC BY-SA 3.0
11 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 14, 2021 at 13:30 | comment | added | amara | Oh, what are the differences between those? | |
| Jan 14, 2021 at 12:38 | comment | added | kaiser | Your info about C ist just wrong. C doesn't really have any "Object-Creation". There are no objects at all. Creating an object on stack is so damn fast. Allocation Heap-Memory is expensiv, but that has nothing to do with "Object-Creation". | |
| Sep 17, 2015 at 10:21 | comment | added | juanchopanza | Ehm, you don't always need to search for free memory to instantiate an object in C. | |
| May 24, 2012 at 19:58 | comment | added | someguy | By the way, with HotSpot, what Jesper described isn't different from what I described. It's possible to just have stack allocation, but I don't think HotSpot does this, or at least that's the impression I get. The advantage being, as opposed to scalar replacement, that the object can be passed as an argument to another method. Edit: I suppose theoretically there's no such limitation but I guess it's not optimal in practice. | |
| May 24, 2012 at 19:31 | comment | added | Joachim Sauer | @someguy: I've read about it some time ago as the next thing, but didn't follow up to check if it's already done. It's excellent news to hear that we already have this. | |
| May 24, 2012 at 15:02 | comment | added | someguy | @Joachim Sauer: That's kind of what is done in the newer implementations of the HotSpot VM. It's called scalar replacement. | |
| May 23, 2012 at 5:34 | comment | added | Joachim Sauer | An the next step for escape analysis is to "allocate" memory for small object purely in registers (for example a Point object could fit in 2 general purpose registers). | |
| May 22, 2012 at 14:28 | comment | added | Jesper | The newer versions of Java can do escape analysis, which means that it can allocate memory for objects that don't escape a method on the stack, so that cleaning them up is free - the garbage collector doesn't have to deal with those objects, they're automatically discarded when the method's stack frame is unwound (when the method returns). | |
| May 22, 2012 at 13:16 | comment | added | benzado | +1 Even though the garbage collector "just works", every Java programmer should learn about the generational garbage collector. | |
| May 22, 2012 at 2:25 | history | edited | amara | CC BY-SA 3.0 | added 314 characters in body |
| May 22, 2012 at 2:20 | history | answered | amara | CC BY-SA 3.0 |