XMLHttpRequest内存泄漏 [英] XMLHttpRequest Memory Leak

查看:150
本文介绍了XMLHttpRequest内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我从开发侧边栏小工具开始,该小工具可以从不同的Web界面读取一些统计信息.我读了一些帖子,他们告诉他们XMLHttpRequest是完成它的唯一方法.所以我正在编码某些东西,并且可以与某人一起工作如果小工具运行了很长时间,则出现问题,sidebar.exe需要大量的RAM,并且CPU值也会增加.所以我的问题是如何解决这个问题.我发表了一些关于它的文章,但我没有找到好的解决方案.我希望您能为我提供帮助,因为我已经花了很长时间才弄清楚.这很伤我:)

下面是代码:

Hello,

i've started with developing a sidebar gadget for reading some stats from different webinterfaces. I read some posts an they told that XMLHttpRequest is the only method to get it done. So i'm coding something and it works with one  problem if the gadget is running a long time the sidebar.exe need a huge amount of RAM and the CPU value is also increasing. So my question is how to solve this problem. i ret some posts about it and i didnt find good solutions for that. i hope you can help me because i took already a long time to figure it out. that hurts me :)

here's the code:

 <script type="text/jscript" language="jscript">
            // function for XMLHttpRequest for multiple pages
			function funcHttpRequest(url, container) {
					var xmlHttp = null;
						xmlHttp = new XMLHttpRequest();
					if (xmlHttp) {
						xmlHttp.open('GET', url, true);
						xmlHttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
						xmlHttp.onreadystatechange = function () {
							if (xmlHttp.readyState == 4) {
								document.getElementById(container).innerHTML = xmlHttp.responseText;
							}
						};
						xmlHttp.send(null);
					}
				}
			function funcDisplay() {
				// function to refresh only the changing content
				funcHttpRequest('http://url1', 'container1');
				funcHttpRequest('http://url2', 'container2');
				funcHttpRequest('http://url3', 'container3');
				funcHttpRequest('http://url4', 'container4');
				funcHttpRequest('http://url5', 'container5');
				// recall for refreshing every second
				setTimeout("funcDisplay()", 1000);
			}
            function init()
            {
                var oBackground = document.getElementById("imgBackground");
                oBackground.src = "url(images/background.png)";
				//call function to display the values of the webinterface
				funcDisplay();
            }
        </script>

我也尝试使用POST方法,但刷新时间很长,并且内存问题已经存在.
您将非常感谢您解决此问题,如果需要,还可以提供更多;)

无论如何,还是感谢您阅读本文,如果我已经忘记了一些东西,请告诉我是否需要其他信息.

i try this with POST method too but the refreshing time is to long and the ram problem is already there.
you will get a big thanks for solving this and more if you want ;)

thanks anyway for reading this and if ive forgotten something pls tell me if you need additional infos.

推荐答案

您好,

仅MS Internet Explorer有问题. Firefox浏览器似乎运行良好.
因此,这可能是IE中的错误.

Hello,

This seems to be a problem only with MS Internet Explorer. The Firefox browser seems to work well.
So, it could be a bug in IE.


这篇关于XMLHttpRequest内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆