Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Infinity job to refresh UI leads to memory leak(Display + asyncExec + infinity loop + memory leak)
Infinity job to refresh UI leads to memory leak [message #534462] Wed, 19 May 2010 05:39 Go to next message
Eclipse UserFriend
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 #534709 is a reply to message #534462] Thu, 20 May 2010 01:29 Go to previous messageGo to next message
Eclipse UserFriend
On 19/05/10 3:09 PM, Andrew wrote:
> 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") {
> // ....
> }
>


Why can't you use UIJob?

- Prakash
Platform UI Team, IBM

www.eclipse-tips.com
Re: Infinity job to refresh UI leads to memory leak [message #534722 is a reply to message #534709] Thu, 20 May 2010 03:06 Go to previous messageGo to next message
Eclipse UserFriend
I can't use UIJob, coz getting data from server is long time operation and it will make the UI unresponsive until it completes.
Re: Infinity job to refresh UI leads to memory leak [message #534856 is a reply to message #534462] Thu, 20 May 2010 09:54 Go to previous messageGo to next message
Eclipse UserFriend
Andrew wrote:
>
> 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();
> }

Where is the above code? In the asyncExec(*)?

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
Re: Infinity job to refresh UI leads to memory leak [message #534923 is a reply to message #534856] Thu, 20 May 2010 12:14 Go to previous messageGo to next message
Eclipse UserFriend
No, this code in a button handler which start infinity update job.
Re: Infinity job to refresh UI leads to memory leak [message #534979 is a reply to message #534923] Thu, 20 May 2010 17:04 Go to previous messageGo to next message
Eclipse UserFriend
Andrew wrote:
> No, this code in a button handler which start infinity update job.
>

boolean ok = true;
while(ok) {
try {
Thread.sleep(10);
}
catch (InterruptedException e) {
e.printStackTrace();
} j.scheduler();
}


This code can't be on the UI thread, it will block it. I presume a
button handler is an SWT Listener or SelectionListener.

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
Re: Infinity job to refresh UI leads to memory leak [message #535009 is a reply to message #534979] Thu, 20 May 2010 23:15 Go to previous messageGo to next message
Eclipse UserFriend
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 (update button start update job which load data from server and update UI)...

[Updated on: Thu, 20 May 2010 23:17] by Moderator

Re: Infinity job to refresh UI leads to memory leak [message #535152 is a reply to message #535009] Fri, 21 May 2010 08:33 Go to previous message
Eclipse UserFriend
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
Previous Topic:Force loading of a stacked view
Next Topic:Custom Label Provider not firing for org.eclipse.core.resources.IFile
Goto Forum:
  


Current Time: Tue Jul 22 17:45:50 EDT 2025

Powered by FUDForum. Page generated in 0.04819 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top