I'm working on a J2EE application and, for some reason, Internet Explorer (7) occasionally locks up on me (it will freeze, go into "Not Responding", and has to be killed manually through the task manager). I have not tested this extensively with other browsers as my user-base is primarily IE-only. I have one page, in particular, that uses a lot of Java Script for the UI controls - this is the page that is giving me trouble. I am using both JQuery and Scriptaculous on the page.
I'm having a very difficult time debugging this for a couple reasons.
1. It only happens intermittently and almost never on my system.
2. When it does lock, it doesn't lock up "in my code". Rather, the browser will lock up when a user clicks on a control. Most often, the user will click on a span with an onclick and the browser will lock up prior to invoking the onclick method. Just yesterday, though, the browser locked up when a user tried opening a drop-down list, which has no onclick associated with it.
My best guess, at this point, is that I have a memory leak going on. Unfortunately, I've been unable to identify it with certainty and, most certainly, I haven't been able to fix it. I believe the issue lies in this code (although I'm not certain):
This code is invoked any time someone wants to add an "indicator" to the page. It's not essential to know what an indicator is, but it is represented with a single line of text. Beside that line of text is a little graphic "Minus.gif" that allows the user to click on the element and remove it from the page.
Is there anything here that looks like it could cause problems? I realize this is a rather vague question, but I'm very unsure of exactly where this problem lies. This is my best guess.
I don't see anything horrendous in your code that would drive IE batty. but then, it takes so little.
But, of course, the problem could lie elsewhere.
By the way, if you're using jQuery 1.3, you can simplify your code by adding the click handler to the new span using live(), rather than needing a separate function to bind it after the fact.
Joined: Dec 20, 2001
Bear Bibeault wrote:By the way, if you're using jQuery 1.3, you can simplify your code by adding the click handler to the new span using live(), rather than needing a separate function to bind it after the fact.
Originally, I was doing that (or something very similar) but I was concerned that the handler might be getting references to all the method parameters and therefore causing a memory leak. So I moved it to a method on its own, hoping to minimize the issue. It seems to have made it somewhat better (it doesn't lock up as often), but it obviously hasn't solved the issue.
Have you watched the task manager to see if the page climbs in memory. Also it is wise to have people clear their cache Sometimes a full cache can cause havoc on a machine.
Joined: Dec 20, 2001
Eric Pascarello wrote:Have you watched the task manager to see if the page climbs in memory. Also it is wise to have people clear their cache Sometimes a full cache can cause havoc on a machine.
I've done all sorts of stuff to try to monitor the memory usage of this code. The test I was really trying to get something out of was to put this code into a large loop (executing 10,000 times, or so) and then watch a memory monitor to see what was happening. It did appear to use up a little more memory, but it wasn't much. That said, I have users that are running Windows XP with 512 MB of memory - they don't have a lot of room to spare.
I did make some changes and reran those tests and it appears that the page is now a little easier on the memory usage, but it's still crashing.
I can certainly try the cache clearing to see if that makes a difference.