Quantcast
Viewing all articles
Browse latest Browse all 15

Answer by amara for Should we avoid object creation in Java?

Actually, due to the memory management strategies that the Java language (or any other managed language) makes possible, object creation is little more than incrementing a pointer in a block of memory called the young generation. It's much faster than C, where a search for free memory has to be done.

The other part of the cost is object destruction, but it's hard to compare to C. The cost of a collection is based on the amount of objects saved long-term but the frequency of collections is based on amount of objects created... in the end, it's still much faster than C-style memory management.


Viewing all articles
Browse latest Browse all 15

Trending Articles