Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8881651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:23:23+00:00 2026-06-14T20:23:23+00:00

It would seem as if it should. But could anyone affirm or deny it?

  • 0

It would seem as if it should. But could anyone affirm or deny it?

Related are:

Catching java.lang.OutOfMemoryError?

Is it possible to catch out of memory exception in java?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:23:24+00:00Added an answer on June 14, 2026 at 8:23 pm

    Does garbage collection run after OutOfMemoryError is thrown in java?

    It certainly runs before the OOME is thrown. Indeed, the OOME is typically thrown as a result of the garbage collector finding that it cannot reclaim enough space to satisfy an allocation request1.

    Whether it runs after the OOME is thrown depends on what the application does. If the application attempts to continue, the GC will typically run the next time that the application asks for more memory … in its continued execution.

    1 – In fact, it is possible to configure the GC to throw an OOME when it detects that it is spending too much time garbage collection. In this case, the JVM may well have a useful amount of unallocated memory in hand.


    Aaron Digulla says this:

    So in a carefully designed application, you can catch and handle OOME and the program will survive and continue working.

    This is true, but it not something that you should normally do, for two different reasons.

    The first reason is that an OOME can be thrown anywhere that a thread attempts to allocate memory. Whatever the JVM was doing at the time will be terminated … up to the point where the OOME is caught. For instance:

    • If the thread was in the middle of updating a shared data structure (under a lock), then the data structure will be left half-updated.

    • If the thread was due to notify some other thread, then that notification will never happen and the other thread will be stuck waiting.

    • If the thread didn’t catch the OOME, then it will exit, and if nothing else notices then you are potentially left with an application that doesn’t work anymore.

    The problem is that these “breakages” are hard to detect or predict, and hard to recover from.

    The second reason is that an OOME is typically indicative of one of the following things:

    • You attempted to perform a computation with insufficient heap memory. If you attempt to recover from the OOME, you are likely to run into the same problem over again.

    • Your application has a memory leak; i.e. some data structure in your application is keeping references to “rubbish” objects, and preventing them from being reclaimed. The chances are that if you attempt to recover from the OOME, nothing will change, and you will run into the same problem again, and again, and again.

    So, the preconditions for successful recovery are that:

    • you know that the OOME cannot have damaged anything in the JVM that matters, AND
    • you know that you are not going to run into the OOME again … because the root cause still exists.

    These are HARD preconditions to meet … in most applications. If they are not met, then there is a good chance that attempting to recover from an OOME will leave it in a worse state than if you have exited and restarted the application.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Normally I would just use URL GET parameters but CodeIgniter doesn't seem to like
I know this should be easy to find via google, but I can't seem
It would seem that IE7 puts an extra 1px of spacing above and beneath
This would seem to be the case in Firefox 3.5+, there I can instantiate
The well-cited RIP Hash rocket post would seem to imply the Hash Rocket syntax
What are the best use cases for anonymous types? It would seem to me
Hi I seem to be at an ORM Tool crossroad and would like some
It doesn't seem like it would be too hard to implement in assembly. gcc
They both seem exceedingly similar and I'm curious as to which package would be
I seem to be missing something obvious here, why would I want more than

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.