Timeline for Object caching in this code too expensive?
Current License: CC BY-SA 3.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 20, 2015 at 0:09 | comment | added | imel96 | Obviously jvm people saw the problem that you're having and got there first. | |
| Feb 17, 2015 at 22:15 | answer | added | James Youngman | timeline score: 3 | |
| Dec 25, 2014 at 10:03 | history | tweeted | twitter.com/#!/StackProgrammer/status/548056421217341440 | ||
| Dec 24, 2014 at 19:10 | history | edited | gnat | CC BY-SA 3.0 | spelling, formatting |
| Dec 24, 2014 at 18:58 | history | edited | user22815 | CC BY-SA 3.0 | spelling/grammar |
| Dec 24, 2014 at 12:58 | comment | added | user161357 | Searching about your topic I have found this interesting answer (I would say related, not duplicated): programmers.stackexchange.com/a/149569 | |
| Dec 24, 2014 at 12:33 | comment | added | Doval | Unrelated to this question but related to the problem you're trying to solve, pooling objects may have worse performance if the memory where the pool resides gets evicted from the CPU cache. You might get a cache miss accessing the object pool, and you might get a second miss accessing the object itself. I imagine the heap area where new objects are allocated is generally hot in the cache and the JVM can use the stack instead in certain cases. You should definitely benchmark both approaches in your actual application and see which one fares better. | |
| Dec 24, 2014 at 12:19 | comment | added | Doval | Instances of NewVsCloneTest can be initialized with statically-known data, and that data happens to be the default value for all the fields. That probably makes a difference. The JVM might also be optimizing the instantiations away since you don't actually do anything with them, while the Stack code has to decrement and increment a variable and the array code has to check the index and that the class of object can be stored in that kind of array. Try adding an operation like incrementing a, b or c and see if the relative speeds. | |
| Dec 24, 2014 at 7:18 | review | Close votes | |||
| Dec 24, 2014 at 15:45 | |||||
| Dec 24, 2014 at 6:55 | history | asked | tkausl | CC BY-SA 3.0 |