Re: [OpenMap Users] Removing Layer from MapHandler

From: Don Dietrick <dfdietrick_at_gmail.com>
Date: Mon, 19 Sep 2011 17:56:23 -0400

Hi Marc,

I think what's happening is the MapBean is holding on to removed
layers until the projection changes. Once a layer has been removed
and the map projection is changed, the layer should be garbage
collected.

The purpose of this is to keep the layer in the dark about when it's
actually removed, in case the user clicks a layer off/on/etc without
changing the projection. This prevents having layers redo work that
is valid for the current projection and keeps them ready to
immediately repaint their contents if re-added to the map.

I just ran a test using a profiler, and my layers were gone after the
projection change.

Hope this helps,

Don

On Mon, Sep 19, 2011 at 5:15 PM, Marc Benstein <MARC.D.BENSTEIN_at_saic.com> wrote:
> Just to confirm that this is potentially an openmap issue. I added
> com.bbn.openmap.layer.test.TestLayer and removed the layer using MapHandler
> as well as LayerHandler. There is definitely a leak. However, it could be in
> the JDK.
>
> On 09/19/2011 02:55 PM, Marc Benstein wrote:
>>
>> Don,
>> Thanks for the reply. I was wrong before _all_ layers that I add to
>> MapHandler or the LayerHandler fail to release the added layer object on
>> remove.
>>
>> Something is keeping these objects around in memory. The setList(null)
>> call only frees the data which is the majority of memory. However, the
>> layer object is still sitting around somewhere and the setList(null) is
>> not needed if the layer itself gets freed. I will dig further. Unless
>> you know of the cause.
>>
>> On 09/16/2011 04:51 PM, Don Dietrick wrote:
>>>
>>> Hi Marc,
>>>
>>> Removing them from the MapHandler should work, although I generally
>>> deal with the LayerHandler directly. Adding setList(null) is a good
>>> idea for dispose(), though, I'll add that.
>>>
>>> - Don
>>>
>>> On Fri, Sep 16, 2011 at 6:36 PM, Marc
>>> Benstein<MARC.D.BENSTEIN_at_saic.com> wrote:
>>>>
>>>> Hi openmap-users,
>>>>
>>>> I am having trouble removing layers from the MapHandler. I have a few
>>>> layers
>>>> that extend OMGraphicHandlerLayer and some that extend Layer. I add
>>>> them all
>>>> to MapHandler using the add(Object) method. However, even after I remove
>>>> them using MapHandler.remove(Object) they are still sitting around
>>>> leaking
>>>> memory. I found that if I override dispose() and call super.dispose()
>>>> along
>>>> with setList(null) the layers that extend OMGraphicHandlerLayer are
>>>> garbage
>>>> collected. Unfortunately, the classes that extend Layer do not get gc'd.
>>>> They are very simple layers that only override
>>>> projectionChanged(ProjectionEvent) and paintComponent(Graphics).
>>>> Consequently, dispose() along with remove(Object) calls do not remove
>>>> them
>>>> completely.
>>>>
>>>> I have a suggestion to the maintainers to override dispose() in
>>>> OMGraphicHandlerLayer and calling setList(null) along with
>>>> super.dispose().
>>>>
>>>> How do I _really_ remove the classes that extend Layer from the
>>>> MapHandler?
>>>>
>>>> Thanks,
>>>>
>>>> --
>>>> Marc Benstein
>>>> 505-830-6763
>>>>
>>>> --
>>>> [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"]
>>>>
>>
>> --
>> [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"]
>
> --
> [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"]
>

--
[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 Sep 19 2011 - 17:58:12 EDT

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