We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › What happens to millis() after 49 days
Page Index Toggle Pages: 1
What happens to millis() after 49 days? (Read 351 times)
What happens to millis() after 49 days?
Mar 2nd, 2009, 3:34pm
 
Hi

I was just wondering what happens when a sketch has been running for
49 days and the int that stores it is theoretically filled up?

4294967295/1000/60/60/24 = 49 days

I guess the same goes for frameCount(), well and a also in other languages.

Nothing important, just a thought Smiley
Re: What happens to millis() after 49 days?
Reply #1 - Mar 2nd, 2009, 4:48pm
 
There was a bug in Windows NT which has troubles after 49 days... Of course, Microsoft corrected that a long time ago.

Java actually uses a long, so do Processing in its internal variable millisOffset (time stamp when the sketch starts).
But indeed, millis() return an int, so we will have an overflow. After 25 days, since int is signed. So value will become negative, probably.
Consequences depend on program, of course.
frameCount should take longer to have a problem...

Now, except perhaps for servers, computers rarely run more than a month without being restarted. At least with Windows, some critical updates restart forcefully the compter!
Even so, you even more rarely run graphical applets that long.

But hey, that's a problem to take in account in some (rare) cases, you are right to rise it. Smiley
Re: What happens to millis() after 49 days?
Reply #2 - Mar 2nd, 2009, 5:51pm
 
Thank you for the answer PhiLho:)

I actually never gave it much thought, before today, depending on the language you will get different exceptions when running into to an overflow, I just assumed that the core classes took these things into account.

I guess you are right that the OS will need a restart before the sketch will, but still, in a perfect world the app Im doing should sit in the background and do it's little thing forever.

Hmm maybe I'll make it throw an exception and make a bit of "noise" so it will be restarted by someone.

Page Index Toggle Pages: 1