Does HVMenu 5.4 have a memory leak?
Announcement
Collapse
No announcement yet.
HVMenu memory leak?
Collapse
X
-
You really can't have a memory leak in Javascript, just poorly designed code.
Memory leaks occur when variables are not deleted, or when the garbage collector (we're talking about C++ and Java here) gets confused when two variables reference each other.
In Javascript, even if variables reference each other, it is so high level and insignificant that you usually don't notice anything. As soon as the page is unloaded, any memory taken up the Javascript code will be released.
What more often happens when JS slows down is that:
1. A lot of math is taking place. I've written a grapher in SVG, and when graphing intensive functions or polar equations, it can slow down a lot. It will even crash if generating too many calculations.
2. A lot of inefficient coding, or lots of resource-intensive actions. Some (many) DHTML effects go about things in ways which eat up resources. Moving objects on screen take an especially good deal of resources. You'd be surprised in some cases. And many effects use for loops, which means whatever effect will be repeated, and if its costly, may start slowing down the browser.
For example:
var div = document.createElement('div');
div.setAttribute('style', 'position: absolute;');
document.body.appendChild(div)
Will run faster than:
var div = document.createElement('div');
div = document.body.appendChild(div);
div.setAttribute('style', 'position: absolute;')
Because div will have been rendered in the second one, then moved, while in the first one it is rendered in the final position to start.
Its small little things like that have the most drastic effects on DHTML imho.
So, as to your original question, I can say it doesn't have a memory leak per-se, but it may be performing actions not necessary, or your cpu just may be too slow, or if youi have other intensive effects, that may be the cause, etc.
Care to post a link?
-
Oh, BTW, since this is a Dynamic Drive script, I'll move it to the appropriate forum.
Comment
Comment