|
|
|
|
|
by bitcharmer
1640 days ago
|
|
Did you also implement object pooling for the Java variant (commonly used in high perf apps)? Something tells me that didnt happen because you saw "cpp running circles around Java" so you got the result you wanted and just stopped there. If you did, you wouldn't be making this comment. |
|
In the specific case I don't think you need to; I've seen generated code (from java sources) simply reuse an object in a tight loop. IOW, it doesn't allocate new memory for the instance within a loop, for each invocation of the loop. The memory for the instance is allocated once and then reused.
(For a small allocation (a small instance) I would expect a smart compiler to not allocate anything and simply create the for-loop instance on the stack).