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

  • Home
  • SEARCH
  • 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 6620537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:06:49+00:00 2026-05-25T21:06:49+00:00

What would be the behavior of a Java program on getting OutOfMemoryError . Is

  • 0

What would be the behavior of a Java program on getting OutOfMemoryError. Is there any defined behavior? Will the process crash or would it go into wait/sleep state?

Update: if I am not handling it in my code?

  • 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-05-25T21:06:50+00:00Added an answer on May 25, 2026 at 9:06 pm

    And OutOfMemoryError is handled like any other exception:

    • If it is caught, then nothing more happens.
    • If it is not caught, then either the threads or the threads groups uncaught exception handler handles it. This pretty much always leads to the thread being stopped.

    However there are two factors that are not really there in other exceptions:

    • OutOfMemoryError is an Error and not an Exception. This means that it’s very unlikely to be caught anywhere: You should not try to catch an Error generally (with very few exceptions) and it’s not usually done, so the chances of it being handled are rather low.
    • When an OutOfMemoryError happens and no object become eligible for GC because of that, then you’ll still have little memory left and chances are that you’ll run into the exact same problem again later on.

    And if the thread this happens to is the only non-daemon thread (often, but not necessarily, that’s the main thread, that executes the main method), then that thread getting killed results in the whole JVM shutting down (which is often perceived as “a crash”).

    So the tl;dr is: It will probably kill the thread, and if the memory-issue is not solved, then this can happen to more and more threads.

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

Sidebar

Related Questions

I was wondering if in Java I would get any odd behaviour if I
Do you know any implementation / technique which would provide similar behavior as Viewstate
Is there a function built into Java that capitalizes the first character of each
So I've got an application whose window behavior I would like to behave more
I would like to have alternate behavior during a print stylesheet on a web
I would like to change the default behavior of Joomla's password reminding mechanism. I
I would like to override the default behavior of the offsetParent member of all
I would want to simulate the behavior of a table with div. I have
I would like to reproduce UIScrollView's flick-to-scroll behavior, but I don't want to use
I would like to create a file whose descriptor would have some customizable behavior.

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.