Help! Javascript alert 'Out of memory'

Discussion in 'JavaScript' started by Imozeb, Mar 29, 2010.

  1. #1
    Javascript keeps popping up an alert box stating 'out of memory line #'. How can I fix this?

    I have about 4 AJAX calls, 3 setIntervals, 4 window., and about 20 functions().

    Please give me advice on how to fix this!

    Thanks.

    ~imozeb :)
     
    Imozeb, Mar 29, 2010 IP
  2. Amator

    Amator Well-Known Member

    Messages:
    1,424
    Likes Received:
    55
    Best Answers:
    0
    Trophy Points:
    165
    #2
    what is the code ?
     
    Amator, Mar 29, 2010 IP
  3. Imozeb

    Imozeb Peon

    Messages:
    666
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It is alot of code so I wasn't sure if I should post it here, about 1000 lines (just for the javascript) split across three files (Different APIs). But mainly it consists of 4 AJAX calls, 3 setIntervals, 4 window.vars, and about 20 or so functions comlex functions and about 30 minor functions (5 or so lines each). I think it might be the setIntervals that are doing it because there are so many of them and on the last file when I took out the setInterval() it worked. If you think the setInterval() is the problem could you tell me and I'll post that API here so you can see it.

    Could you give me any hints on what to look for to delete? And are 4 AJAX calls on one page to many. Only one of them is called repeatedly.

    Thanks.

    ~imozeb
     
    Imozeb, Mar 29, 2010 IP
  4. Nyu

    Nyu Peon

    Messages:
    79
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Well then post the setInterval which you commented out to make your script work and any function you call in that setIinterval. That should give us some more info and we can take a look at whats going wrong ;)
     
    Nyu, Mar 30, 2010 IP
  5. Imozeb

    Imozeb Peon

    Messages:
    666
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Right. Here's the code. (Note: there are other function calling setInterval and AJAX scripts but they do not interact at all with this function)

    Javscript Code:
    
    //parse and output data
    function ratingoutput()
    {
    	//check non existent buttons and items
    	if (window.ratingstarcheck == null){ window.ratingstarcheck = document.getElementById("ratingstar5"); }
    	if (window.ratingoutputcheck == null){ window.ratingoutputcheck = document.getElementById("ratingoutput"); }
    	
    	//output data
    	if (xmlhttprating.readyState == 4 && window.ratingoutputcheck != null)
    	{
    		//parse data
    
    		
    		//print data
    		document.getElementById('ratingoutput').innerHTML = xmlhttprating.responseText;
    	}
    	tr = setInterval(ratingoutput(), 2000);
    	loopfunction()
    }
    
    //call rating output function
    xmlhttprating.open("POST","../../assets/API/API_Ratings/ratingsfunction.php",true);
    xmlhttprating.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlhttprating.setRequestHeader("Connection", "close");
    xmlhttprating.send('do=routput');
    
    ratingoutput()
    
    
    Code (markup):
    The code isn't finished yet cause of the error. But this is what I have now.

    Thanks.

    ~imozeb :)
     
    Imozeb, Mar 30, 2010 IP
  6. Imozeb

    Imozeb Peon

    Messages:
    666
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I figured it out. I needed single quotes around the function().
     
    Last edited: Mar 31, 2010
    Imozeb, Mar 31, 2010 IP