[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recursion in JavaScript

Paul Khramtsov wrote:
> My name is Pavel Khramtsov
> Help me please to answer on the following question:
> What is happened when Navigator executes the following code:
> function clock()
>               {
>                new_date = new Date()
>                window.document.form1.f_clock.value = new_date.getSeconds()
>                id = setTimeout("clock()",1000)
>               }
> <BODY onLoad="clock()">
> It's not recursive, per se.  What's happening is that you are spawning a 
process, what would be called a fork in unix, that remains in the 
background until the time specified.  This works all right in true 
multithreaded environments (or even in the quasi-true 
multitthreading environment of Windows 95), but since 3.1 doesn't have 
any explicit way to make a multithreading process work, it has to spawn 
a new program in memory that can handle this, which probably doesn't get 
cleaned out by the time the call is made again.  I would guess that this 
is one area where there may be a memory management bug, since I've heard 
other people talk about similar problems with the setTimeout function.

Kurt Cagle
Cagle Communications
(206) 557-8532