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 3360432
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:59:30+00:00 2026-05-18T02:59:30+00:00

I have a critical process running in java (1.6), with a registered shutdown hook.

  • 0

I have a critical process running in java (1.6), with a registered shutdown hook. In some instance where I get a OOM issue (more details below about the issue), the process stops suddenly, I don’t get any of my logs, my catch(Throable x) is not catching the exception.

But the shutdown hook works. So if there was a way to know that the process is going to shutdown due to some nasty OOM, I could log necessary info before exiting.

Is there a way to do this?

About the OOM:
Not sure what is the exception because as I said it does not get caught. I know it’s a OOM because I start the process with

-XX:+HeapDumpOnOutOfMemoryError

and I get a heap dump file. In other cases an exception is caught, and it’s a ava.lang.OutOfMemoryError: GC overhead limit exceeded. But not sure it’s always this case.

EDIT:

In case it is not clear: I am not trying to prevent the OOM as it can happen for valid reasons in some scenario, I just want to make sure it is clear in the app log files

My question is: is it possible to find out process is shutting down due to an OOM while in the shutdown hook?

I need to do this programatically and from the same process.

For now the best approach is see if it exists a heap dump file java_pid_pid of process_.hprof (I know the pid) with recent date and deduce there was an OOM.
I guess I could try Runtime.getRuntime().freeMemory() and report the issue if the memory available is very low, but not sure how reliable is that, maybe when the process is shutting down it has already released much memory, the approach above is best I think.

  • 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-18T02:59:31+00:00Added an answer on May 18, 2026 at 2:59 am

    OOMs are tricky because if JVM is out of memory it might not run exception handling code due to a new OOM being thrown.

    Try setting default uncaught exception handler. It will catch all uncaught exceptions.

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

Sidebar

Related Questions

I have a PHP script that sends critical e-mails. I know how to check
I have a slapd LDAP server which is critical to my application. I want
I have used IPC in Win32 code a while ago - critical sections, events,
We are running an web application that is using Java 64bit 5 gigs of
I have been given the task of re-writing some libraries written in C# so
I am running into a critical conflict of sorts. My app is a remote
I have a server process bound to a port that receives network packets at
I have a C++/MFC application I need to restructure. The app used to process
Background: I have a performance-critical query I'd like to run and I don't care
Have just started using Google Chrome , and noticed in parts of our site,

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.