Server-Push/ asyncExec / java.lang.OutOfMemoryError [message #111654] |
Mon, 10 November 2008 08:37  |
Eclipse User |
|
|
|
Hi,
I’m trying to accomplish a server-push for my application.
Referring to this http://www.devx.com/webdev/Article/36101/1954 (Another
Eclipse RAP Test Drive: An Online Newsticker)
The current application is working with Spring-RMI for server
communication and is already running.
My results while creating this peace of software for the server push are:
public void createPartControl(Composite parent){
…
UICallBack.activate("notifierId");
Thread notifierThread = new Thread(createRunnable());
notifierThread.setDaemon(true);
notifierThread.start();
}
private Runnable createRunnable() {
return new Runnable() {
public void run() {
boolean running = true;
Runnable r = new Runnable(){
public void run() {
//do something
}
};
while (running) {
t.getDisplay().asyncExec(r);
}
t.getDisplay().asyncExec(new Runnable() {
public void run() {
UICallBack.deactivate("notifierId");
}
});
}
};
}
Now, my question:
Is that generally the right way to accomplish a server-push?
and:
I am struggling with this exception:
Exception in thread "Thread-6" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Unknown Source)
at java.util.Arrays.copyOf(Unknown Source)
at java.util.ArrayList.ensureCapacity(Unknown Source)
at java.util.ArrayList.add(Unknown Source)
at
org.eclipse.rwt.internal.lifecycle.UICallBackManager.addAsyn c(UICallBackManager.java:114)
at org.eclipse.swt.widgets.Display$1.run(Display.java:614)
at
org.eclipse.rwt.internal.lifecycle.UICallBackServiceHandler. runNonUIThreadWithFakeContext(UICallBackServiceHandler.java: 423)
at
org.eclipse.rwt.lifecycle.UICallBack.runNonUIThreadWithFakeC ontext(UICallBack.java:44)
at org.eclipse.swt.widgets.Display.asyncExec(Display.java:612)
at rap.view.WorktimesView$6.run(WorktimesView.java:240)
at java.lang.Thread.run(Unknown Source)
Any ideas what’s going wrong or how to prevent this error?
Thanks,
Konstantin May
|
|
|
|
|
Re: Server-Push/ asyncExec / java.lang.OutOfMemoryError [message #112101 is a reply to message #112049] |
Tue, 11 November 2008 07:00  |
Eclipse User |
|
|
|
Originally posted by: rherrmann.innoopract.com
Konstantin,
if you want to learn more about how the UI Callback mechanism works
internally, you may want to search the news archive (e.g. ui callback).
One thread related to this is:
http://dev.eclipse.org/newslists/news.eclipse.technology.rap /msg01751.html
HTH
Rüdiger
May wrote:
> Thanks, that is much better to handel.
>
> I have changed the code to this:
>
> private Runnable createRunnable() {
> return new Runnable() {
> public void run() {
> Job job = new Job("myJob") {
> protected IStatus run(IProgressMonitor monitor) {
> // fetch something from Server
> t.getDisplay().asyncExec(new Runnable(){
> public void run() {
> //updated UI
> }
> });
> return Status.OK_STATUS;
> }
> };
> job.schedule();
> boolean running = true;
> while (running) {
> job.schedule(1000);
> }
> }
> };
> }
>
> I'm quite a little bit confused, but this doesent't realy look like a
> server-push.I suppose that is more similar to server-polling-mechanism.
>
> Is there a better way for getting events from the server?
> This solution could produce a massive traffic between server an client.
>
> Thanks in advance,
>
> Konstantin May
>
|
|
|
Powered by
FUDForum. Page generated in 0.03611 seconds