Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jan 2004
    Location
    Port Huron, MI, U.S.A.
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Out of Memory error

    LOOK @ SCRIPT FIRST, so paragraph can be more easily understood

    I have a script that, when I try to run it, works a for a about a millisecond, doing many times the math that the script requires (+=275), and then gives me an alert saying OUT OF MEMORY AT LINE 44. Notepad says line 44 is the line w/ the getElementById("~") thing. I think I've made a loop (that made the browser run out of memory, the scripts proccesses to run super fast[which caused the crash because there was no limiter on the script]) before the setTimeout but I don't see where/how.


    Code:
    <script>
    function turny() {
    var XWERT=document.getElementById("RNDRCTY").style;
    XWERT.rotation+=5;
    //Note:later add if(>360) {to0dg}
    var Timer=setTimeout(turny(),1103)
    	}
    function Stoyp() {
    clearTimeout(Timer)
    	}
    </script>
    
    
    
    
    <v:roundrect... onMousedown="turny()" onMouseup="Stoyp()" ...>...
    Oh, was I supposed to put something here? ........

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You need to move your conditional which limits the highend of the increments to above: XWERT.rotation+=5;
    .......

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    And you're clearing a local variable Timer not global. Remove the var keyword in

    var Timer=setTimeout(turny(),1103)

    to make the Timer variable global. Or for good practice, declare Timer with var keyword outside the function.
    Code:
    var Timer;
    function turny(){
      ...
       Timer = ...
    }
    function Stoyp() {
       clearTimeout(Timer);
    }
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #4
    Regular Coder
    Join Date
    Jan 2004
    Location
    Port Huron, MI, U.S.A.
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts
    SUCCESS!! Thanks a lot!
    Oh, was I supposed to put something here? ........


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •