Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Java Garbage Collection Tutorial - Why Garbage Collection might be more important than you think?

  1. #1
    Member
    Join Date
    Nov 2017
    Location
    USA
    Posts
    138
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default Java Garbage Collection Tutorial - Why Garbage Collection might be more important than you think?

    Why Garbage Collection might be more important than you think?

    I have heard from few of my developer friends saying: “Garbage Collection is Automatic. So, I don’t have to worry about it.“ First part is true my friends, i.e. “Garbage Collection is Automatic” on all modern platforms – JVM (Java Virtual Machine), ART (Android Run Time)… But the second part is not true, i.e. “I don’t have to worry about it.” Garbage Collection is automatic, but it’s not free. It comes with a price. In fact, the price can be *very expensive*.

    Poor Garbage Collection can lead to:

    Unpleasant user experience (SLA Breaches)
    Increase the bill from cloud hosting providers
    Puts entire Application Availability under risk
    Let’s discuss them.

    1. Unpleasant user experience (SLA Breaches)

    To garbage collect objects automatically, entire application must be paused intermittently to mark the objects that are in use and sweep away the objects that are not used. During this pause period, all customer transactions which are in motion will be stalled (i.e. frozen). Depending on the type of GC algorithm and memory settings that you configure, pause times can run from few milliseconds to few seconds to few minutes. Thus, Garbage Collection can affect your application SLA (Service Level Agreement) significantly. Frequent pauses in the mobile application can jank the app (i.e. stuttering, juddering, or halting). It can leave a very unpleasant experience for your user.

    2. Increase the bill from cloud hosting providers

    Garbage collection consumes a lot of CPU cycles. Each application will have thousands/millions of objects sitting in memory. Each object in memory should be investigated periodically to see whether they are in use? If it’s in use, who is referencing it? Whether those references are still active? If they are not in use, they should be evicted from memory. All these investigations and computation requires a considerable amount of CPU power.

    Most applications saturate memory first before saturating other resources (CPU, network bandwidth, storage). Most applications upgrade their EC2 instance size to get additional memory rather get additional CPU or network bandwidth. More object creation translates to more frequent Garbage Collection. Thus, you will end up buying more compute power. It will increase the bill from your cloud hosting providers.

    3. Puts entire Application Availability under risk

    Sometimes garbage collection events pause the application for several seconds to several minutes. Sometimes garbage collection events might run repeatedly. When Garbage Collection runs repeatedly, no customers transactions will be processed. When Garbage Collection runs repeatedly, to recover from the situation, the application has to be recycled. Such events can put the availability of your applications under risk.

    Thus, to achieve ‘Wow’ user experience, reduce bills from hosting providers and increase your application’s availability, one would have to study and optimize the Memory/Garbage Collection settings. Tools such as GCeasy.io, HP Jmeter can help you to study and optimize the Memory/Garbage collection settings.

  2. The Following User Says Thank You to Ram Lakshmanan For This Useful Post:

    John Joe (November 28th, 2017)

  3. #2
    Member John Joe's Avatar
    Join Date
    Jun 2017
    Posts
    276
    My Mood
    Amused
    Thanks
    8
    Thanked 19 Times in 19 Posts

    Default Re: Java Garbage Collection Tutorial - Why Garbage Collection might be more important than you think?

    What is the good practice of java heap ?
    Whatever you are, be a good one

Similar Threads

  1. Question about garbage collection
    By dudushr in forum Java Theory & Questions
    Replies: 6
    Last Post: October 31st, 2013, 02:22 AM
  2. Replies: 1
    Last Post: June 12th, 2013, 12:58 PM
  3. Does garbage collection occurs in PERM Area of Java Heap ?
    By javabuddy in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 22nd, 2011, 12:27 AM
  4. Java Garbage Collection and destructors
    By riddhik84 in forum Java Theory & Questions
    Replies: 5
    Last Post: October 1st, 2009, 09:06 AM
  5. Garbage Collection?
    By kalees in forum Collections and Generics
    Replies: 6
    Last Post: September 23rd, 2009, 03:07 AM

Tags for this Thread