0

Server push 页面 IE 内存溢出

asked 2010-07-28 22:45:30 +0800

tabsuny gravatar image tabsuny
102

Hi~

我写了一个Server push页面,每10s去更新一下;具体操作是:
删除一个listbox及其items。
再new一个listbox及其items。同时给每一个listitems 加了一个onclick事件。
此页面跑个二天左右,就会报IE内存溢出的错误!汗~~。
不知到到底是什么原因造成的!
有没有人遇到过这个问题呢?
那又是什么原因造成的呢?!
急切!感谢!

delete flag offensive retag edit

5 Replies

Sort by » oldest newest

answered 2010-07-29 00:03:43 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

請提供代碼及ZK版本

link publish delete flag offensive edit

answered 2010-07-29 04:46:27 +0800

tabsuny gravatar image tabsuny
102

Hi~,
环境:ZK5.0,Tomcat5.5,JDK6.0+, IE6出现时间短,IE7相对出现时间长;
index.zul:

<?page title="Auto Generated index.zul"?>
<zk>
<zscript language="Java">
    import com.test.TestServerPush; 
</zscript>
<button label="Start" width="90px" onClick="TestServerPush.start(win_push)"/>
<listbox id="win_push" width="100%" visible="true" fixedLayout="true" mold="paging" pageSize="99"  multiple="true">
      <listhead>  
      <listheader  label="o,god" width="25%"/>
      <listheader  label="o,god" width="25%"/>
      <listheader  label="o,god" width="25%"/>
      <listheader  label="o,god" width="25%"/>
      <listheader  label="o,god" width="25%"/>
      <listheader  label="o,god" width="25%"/>
      <listheader  label="o,god" width="25%"/>
      <listheader  label="o,god" width="25%"/>
      <listheader  label="o,god" width="25%"/>
      <listheader  label="o,god" width="25%"/>
      <listheader  label="o,god" width="25%"/>
      <listheader  label="o,god" width="25%"/>
      </listhead>
  </listbox>
</zk>

TestServerPush.java:
package com.test;

import org.zkoss.lang.Threads;
import org.zkoss.zk.ui.Desktop;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zk.ui.util.Clients;

public class TestServerPush{
	private static WorkingThread _thragentpush;
	public static void start(Listbox listbox) throws InterruptedException {
		final Desktop desktop = Executions.getCurrent().getDesktop();
		if (desktop.isServerPushEnabled()) {
			;
		} else {
			desktop.enableServerPush(true);
			_thragentpush = new WorkingThread(listbox);
			_thragentpush.start();
		}
	}	
	private static class WorkingThread extends Thread {
		private final Desktop _desktop;
		private final Listbox _listbox;
		public int M_Refresh = 2000;
		private WorkingThread(Listbox listbox) {
			_desktop = listbox.getDesktop();
			_listbox = listbox;
		}
		public void run() {
			try {
				while (true) {
					if (_listbox.getDesktop() == null
							|| !_desktop.isServerPushEnabled()) 
					{
						_desktop.enableServerPush(false);
						return;
					}
					Executions.activate(_desktop);
					try {                      	
                        _listbox.getItems().clear();
						 for (int i = 0; i < 100; i++)
						 {
							Listitem item = new Listitem();
							/*
							item.addEventListener("onClick", new EventListener(){
								public void onEvent(Event e)throws Exception { 
									Clients.evalJavaScript("alert('o,shit!');");	
								}
							});
							*/
							for(int j = 0; j < 12 ; j++){
								Listcell cellTemp1 = new Listcell();
								cellTemp1.setLabel("congkaishi");
								cellTemp1.setParent(item);
								cellTemp1.addEventListener("onClick", new EventListener(){
									public void onEvent(Event e)throws Exception{
										Clients.evalJavaScript("alert('o,shit!');");	
									}
								});
							}
							item.setParent(_listbox);				
						}									 
					} finally {
						Executions.deactivate(_desktop);
					}
					Threads.sleep(M_Refresh);
				}
			} catch (InterruptedException ex) {
			}
		}
	}
}

link publish delete flag offensive edit

answered 2010-08-02 06:38:14 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

請問是使用5.0.3嗎?
所以你的範例要跑2天才會溢出?

link publish delete flag offensive edit

answered 2010-08-05 20:20:43 +0800

tabsuny gravatar image tabsuny
102

hi,
应该是5.0.0
可能是我机器配置好点。换个稍低配置的机器出的概率应该会大点。

link publish delete flag offensive edit

answered 2010-08-05 21:49:33 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

您可以考慮升到5.0.3
我們有做一些內存的優化

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-07-28 22:45:30 +0800

Seen: 545 times

Last updated: Aug 05 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More