[OpenMap Users] Day/Night Layer garbage collection

From: Chase Barrett <chase.barrett_at_issinc.com>
Date: Mon, 6 Feb 2006 10:36:38 -0700

Hello All,

 

We've discovered that when we dispose of a map that includes the day/night
layer, the disposed map is never garbage collected. This is because one or
more Timer objects have the disposed map registered as a listener, and the
map is therefore reachable by reference from an active thread.

 

We've also noticed that if you attempt to update the refresh rate by calling
setProperties() with an updated refresh property, the new Timer kicks in as
expected, but the old Timer still kicks off refresh events according to the
old refresh rate. Updating the refresh rate with a call to setTimer() has
no effect on the refresh events, unless the outside caller also adds the
layer as a listener to the new Timer.

 

For those interested, these are the changes we made to
com.bbn.openmap.layer.daynight.DayNightLayer to address these problems:

 

1) Modified setTimer(Timer):

 

    Replaced:

  

        public void setTimer(Timer t) {

            timer = t;

        }

 

    With:

 

        public synchronized void setTimer(Timer t) {

            if (timer != null)

            {

                timer.removeActionListener(this);

            }

            timer = t;

            if ((timer != null) && (timer.getDelay() > 0))

            {

                timer.addActionListener(this);

            }

        }

 

2) Modified setProperties(String, Properties):

 

    Replaced:

  

        if (updateInterval > 0) {

            timer = new Timer(updateInterval, this);

        }

 

    With:

  

        setTimer(new Timer(updateInterval, null));

 

3) Add an override for removed(Container):

 

        public void removed(Container cont)

        {

            super.removed(cont);

            setTimer(null);

        }

 

 

Hope this helps,

 

Chase




--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Mon Feb 06 2006 - 12:37:17 EST

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:07 EDT