Infinity job to refresh UI leads to memory leak [message #534462] |
Wed, 19 May 2010 05:39  |
Eclipse User |
|
|
|
Hello, I need to update my UI with data from server.
In order to do that I'm using a job:
Job j = new Job("update job") {
// ....
}
When job is finished with status OK I try to update UI with asyncExec:
Display.getDefault().asyncExec(new Runnable() {
// update UI
}
Then If I try to do something like that:
boolean ok = true;
while(ok) {
try {
Thread.sleep(10);
}
catch (InterruptedException e) {
e.printStackTrace();
}
j.scheduler();
}
I'v got a memory leak. Analizing memory heap showed that org.eclipse.swt.widgets.RunnableLock object's are accumulate and cause Out Of Memory. If I'm using
Display.getDefault().syncExec(new Runnable() {
// update UI
}
then all is fine. Can you explain me what's the problem with asyncExec ?
|
|
|
|
|
|
|
|
|
Re: Infinity job to refresh UI leads to memory leak [message #535152 is a reply to message #535009] |
Fri, 21 May 2010 08:33  |
Eclipse User |
|
|
|
Andrew wrote:
> Yes, it will. But is the problem in it ? I need this loop only for
> emulating user update button click (this loop only for quick reproduce
> problem). Without this loop i've got Out Of Memory too after many times
> update button clicking...
Maybe I misunderstand, but basically you need to do short, UI related
work on the UI thread, and whatever other work you are doing on your
second thread. In your real app, you are getting to the end of a Job
and then posting a display,asyncExec(*) right?
You cannot have that loop you posted in the UI thread, even for an
example, or the UI thread will never process any more asyncExecs(*),
since they're done in the display.readAndDispatch() method and your
loop prevents it from returning to that method.
PW
--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm
|
|
|
Powered by
FUDForum. Page generated in 0.04819 seconds