Hello,
I have a JAva program that runs all day long mimicking daemons. IT
calls Thread.sleep between each iteration. I am running it on an NT
server.
Eerything is wrapped in try / catch block...however the program will
sometimes quit. It will not throw an exception, or give any kind of
JVM error. Its as if somerthing wiped it out of memory. Here are the
exact 3 lines of code:
log("sleeping");
Thread.sleep(30000);
log("woke up");
I was thinking that it somehow did not wake up, but I see no trace of
java.exe in the task manager when it quits. I found out through my
research that a java process might sleep and never wake up if the
system time is adjusted during its sleep. However, I don't belieeve
this is happening b/c I don't have a dead java.exe process in the task
manager.
Another hint I recieved was that if someone logs onto the server, and
than logs off, it may send the java.exe a signal to shutdown...which
can be avoided with -XRS command line option. However, I can not
recreate this scenario...
Anyone know what might be going on?
Thanks,
eF.
Ian Mills - 25 Jan 2006 20:23 GMT
> Hello,
>
[quoted text clipped - 27 lines]
> Thanks,
> eF.
It may be worth redirecting stdout and stderr to a file as sometimes
errors will be shown here that are not caught in your try/catch blocks.
Daniel Dyer - 25 Jan 2006 20:23 GMT
> Hello,
>
> I have a JAva program that runs all day long mimicking daemons. IT
> calls Thread.sleep between each iteration. I am running it on an NT
> server.
Are all your threads daemon threads? The JVM will exit when there are
only daemon threads remaining.
How long does the program run for before it dies?
> Eerything is wrapped in try / catch block...however the program will
> sometimes quit. It will not throw an exception, or give any kind of
> JVM error. Its as if somerthing wiped it out of memory. Here are the
> exact 3 lines of code:
What are you catching? Just Exception, or Throwable? If you are using
Java 5 you may also want to look into
Thread.setDefaultUncaughtExceptionHandler, just to make sure.
> log("sleeping");
> Thread.sleep(30000);
> log("woke up");
> I was thinking that it somehow did not wake up, but I see no trace of
> java.exe in the task manager when it quits. I found out through my
> research that a java process might sleep and never wake up if the
> system time is adjusted during its sleep. However, I don't belieeve
> this is happening b/c I don't have a dead java.exe process in the task
> manager.
It could be the JVM has crashed due to some bug or some misbehaving JNI
code.

Signature
Daniel Dyer
http://www.dandyer.co.uk
eftal - 25 Jan 2006 21:01 GMT
Thanks a lot for the response. Actually, the program is not
multithreaded...it is not using Daemon threads...within the main
program there is a while loop that runs forever unless there is a break
in the condition...it is within here that it sleeps and wakes up.
eftal - 25 Jan 2006 21:06 GMT
thanks for your response...yes, I think its JVM...but it seems
arbitrary.
1 - Program is not multithreaded....so its just a main with a while
loop that sleeps / wakes up in the lines I posted. The last log entry
is "sleeping" from the main...it disappears after that. So, no, its
not a daemon thread.
2 - It seems to go down at arbitrary times...sometimes it will run all
day without any issues. Sometimes it'll crash 3-4 hours into operation.
Daniel Dyer - 25 Jan 2006 21:15 GMT
> thanks for your response...yes, I think its JVM...but it seems
> arbitrary.
[quoted text clipped - 6 lines]
> 2 - It seems to go down at arbitrary times...sometimes it will run all
> day without any issues. Sometimes it'll crash 3-4 hours into operation.
Which exact version of the JVM are you using (run java -version)?
Are you using JNI or running any native processes via Runtime.exec()?
Are there any calls to System.exit() anywhere in your code?
What are you doing with the InterruptedException that Thread.sleep can
throw?
Also, Ian's suggestion of redirecting standard error is a good one, it may
reveal some more information.
Dan.

Signature
Daniel Dyer
http://www.dandyer.co.uk
Thomas Hawtin - 25 Jan 2006 22:29 GMT
> I have a JAva program that runs all day long mimicking daemons. IT
> calls Thread.sleep between each iteration. I am running it on an NT
> server.
Is NT still supported?
> Another hint I recieved was that if someone logs onto the server, and
> than logs off, it may send the java.exe a signal to shutdown...which
> can be avoided with -XRS command line option. However, I can not
> recreate this scenario...
Sounds like they were referring to this bug (fixed way back in 1.3.0_04)
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4323062
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/