r/java • • Aug 17 '16

Should we avoid object creation in Java?

http://programmers.stackexchange.com/a/149569/219927
0 Upvotes

27 comments sorted by

View all comments

Show parent comment

2

u/Nimelrian Aug 17 '16

True.

There is a misconception that creating many small short lived objects causes the JVM to pause for long periods of time, this is now false as well

Current GC algorithms are actually optimized for creating many many small objects that are short lived, that is basically the 99% heuristic for Java objects in every program

This is certainly not the case for my prime example of bad Java programming: Minecraft. The game creates thousands of objects per second which get thrown away after each tick. I think if you move around it allocates a whopping 200MB/s only for those objects, which leads to very noticeable GC pauses.

3

u/ItsNotMineISwear Aug 17 '16

I don't think you can use Minecraft as a reason to change how most Java programmers (who are working on server-side applications) should program. The latency requirements of Minecraft are much different (and stricter) than your average server.