Interesting, we did not foresee someone adding the same layer to two maps!
I think the layers would like the option to "cache" some information
between different rendering calls (for example during a pan or zoom).
With that in mind can I ask you to create separate layers for each map? You
can use the same FeatureSource / DataStore implementations as those are
designed to be used from multiple threads?
We can also talk to Andrea to check if several MapRenderers can use the
same Map (and thus Layers) concurrently, for example during "tile"
rendering. If the renderer is grabbing a copy of all the
configuration/styling then this may work out ... If so we could introduce
a MapContent.dispose(true) - to allow control of disposing all the layers.
The other alternative would be to reference count the layers so
MapContent.dispose() can figure out if is the "last" map using a layer and
thus in position to clean up any resources used.
Can I ask you to open a JIRA issue for this discussion, you may also be in
position to test and submit a patch. We have a feature freeze next week so
time is of the essence.
--
Jody
Jody Garnett
On Tue, Jul 8, 2014 at 12:53 AM, Tobias Sauerwein <
tobias.sauerw...@camptocamp.com> wrote:
> Hi!
>
> We are using the class MapContent together with the StreamingRenderer to
> render a bunch of different layers. This works fine, but now we want to
> render the same layers with a second MapContent. The problem is that when
> calling `dispose()` on the first MapContent, that also all layers are
> disposed and the data sources are closed. So that the layers can not be
> used anymore in a second MapContent.
>
> I could simply skip the call to `MapContent.dispose()` and then dispose
> the layers manually at the end. But this shows the error message "Call
> MapContent dispose() to prevent memory leaks", which I do not want to show
> to the users of our library.
>
> For now, I sub-classed MapContent and overwrite `dispose()` and
> `finalize()`, but this feels like a hack. What else could I do? Why are
> layers disposed when disposing MapContent?
>
> Thanks,
> Tobias
>
>
> ------------------------------------------------------------------------------
> Open source business process management suite built on Java and Eclipse
> Turn processes into business applications with Bonita BPM Community Edition
> Quickly connect people, data, and systems into organized workflows
> Winner of BOSSIE, CODIE, OW2 and Gartner awards
> http://p.sf.net/sfu/Bonitasoft
> _______________________________________________
> GeoTools-GT2-Users mailing list
> GeoTools-GT2-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>
------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users