Sign in to follow this  
Concentrate

Java : Garbage Collection

Recommended Posts

Cause they wanted Java to be simpler than C and C++. Garbage collection allows faster development, as there's less complication for the programmer. It's a business decision they took when developing the language. I guess they weighed the cost and benefits, and decided to go with it. Java and the JRE works pretty well, and has gotten quicker over the years.

Share this post


Link to post
Share on other sites
Early implementations of Java didn't have fast heap allocation. They didn't design the language to have efficient allocation, they designed it to be safe. Stack allocation brings issues relating to invalid references. C#, with the benefit of hindsight, allows for value and reference types to get around this.

This article says that modern JVMs perform escape analysis and can stack allocate (or even just use registers) in the case where an object does not live longer than a single function.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this