| Author |
complex algorithm crashing browsers
|
David lorenz
Greenhorn
Joined: Feb 17, 2006
Posts: 3
|
|
I have an algorithm that builds a 2 dimensional array. It can have over 100,000 items. I've implemented this algorithm in java without problem and now have implemented it in javascript and it brings the browser to a halt or displays the message (this is a paraphrase) "a script may be cause your browser to slow down...." Now I guess I'm not surprised but is there something I can do to maybe cleanup the code. Is there a garbage collection thing I can do? The algorithm is a modified Levenshtein that compares paragraphs to see how many words are different.
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
JavaScript will do this when a loop is normally over 10K. Is there a fix, not really. I personally would do send the data up to the server to do the processing and have to come back. Ajax may help out. Eric
|
 |
David lorenz
Greenhorn
Joined: Feb 17, 2006
Posts: 3
|
|
|
We are using Ajax. We may just have the server do it. Though I have just read about modified Levenshteins that use only the 2 rows of the array at a time, so perhaps the whole array need not be stored. This could reduce the sice quite a bit. 10k isn't a very big number though.
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
You also need to realize that if you have this out in the public, someone may be running on a 233 with no memory. Watch how that browser handles the chugging. There are tricks to using setTimeout to do very large loops, but it is slower and not really the best way of handling things. Eric
|
 |
David lorenz
Greenhorn
Joined: Feb 17, 2006
Posts: 3
|
|
Everything was fine as java but everyone wants no download still after all these years. Ajax has opened some doors and I hope javascript and browsers become more robust. They seem to be. We can move the processing to the server. Its just nice if you can have the client do it instead of eating up your server resources. Thanks for your help.
|
 |
 |
|
|
subject: complex algorithm crashing browsers
|
|
|