Hi

 

I have a problem of OutofMemoryError when updating my screen continuously every second after about a day or so

           

 

Below is the thread that does all the updating

/**

             * This thread will take care of updating the Dom structure

             * and the object

             */        

            public class RunUpdate extends Thread

            {

                        int delay;

                        private boolean threadSuspended;

                        RunnableUpdate ru = new RunnableUpdate();

           

                        RunUpdate(int d)

                        {

                                    delay = d;

                                    threadSuspended = false;

                        }

                       

                        public synchronized void pausethread()

                        {

                                    if(!threadSuspended){

                                                threadSuspended = true;

                                                notify();

                                    }

                                   

                        }

                        public synchronized void resumethread()

                        {

                                    if(threadSuspended){

                                                threadSuspended = false;

                                                notify();

                                    }

                        }

                       

                       

                        public void run(){

                                               

                                   

                    while (true) {

                        try {     

                       

                            if (threadSuspended) {

                                synchronized(this) {

                                    while (threadSuspended)

                                        wait();

                                }

                            }

                           //Need by Batik inorder to refresh the svg canvas

                                    Thread.sleep (delay);

                                    um = svgc.getUpdateManager();

                                    System.gc();                            

                                   

                                    um.getUpdateRunnableQueue().invokeAndWait(ru);          

                                                 

                        } catch (InterruptedException e){

                                    System.out.println("RunUpdate over");

                        }catch (java.lang.OutOfMemoryError err ){ //in case of memory error

                                    System.exit(1);                                                 

                        }                     

                    }

                        }

                       

                        public class RunnableUpdate implements Runnable

                        {

                                    public void run(){            

                                                update();            //method to update the dom structure     

                                    }            

                        }

            }                                  

 

 

I’m guessing the problem is the RunnableUpdate ru added to the RunnableQueue causes a RunnableQueue.Link object to be created to link to every Runnable Update

And that does not get deleted eventhough there is only one instances of RunnableUpdate and that’s ru. ? is there a way to update my screen continuously and indefinately?

Thanks a lot

 

Charlie Tang