I can't trigger the warning using 16.0-SNAPSHOT. Also once I remove
mp.getMapContent().dispose();
I get a map too.
But normally I wouldn't change my mapcontent but simply add or remove
layers from the mapcontent, using addLayer and removeLayer
Ian
On 11 July 2016 at 10:57, Julian Hagenauer <[email protected]> wrote:
> Hi,
>
> I am using geotools 14.4. I also wonder why no map is shown at all after
> the massage appeared.
>
> Best
> Julian
> >>>
> *Von: * Ian Turton <[email protected]>
> *An:* Julian Hagenauer <[email protected]>
> *CC:* geotools-users <[email protected]>
> *Datum: * 11.07.2016 11:42
> *Betreff: * Re: [Geotools-gt2-users] MapContent dispose() seems not to
> work
> which version of GeoTools are you using? I'm pretty sure we fixed this
> (bogus) warning at last years FOSS4G code sprint.
>
> Ian
>
> On 11 July 2016 at 08:05, Julian Hagenauer <[email protected]> wrote:
>
>> Hello,
>>
>> I wrote a small test application which updates the MapContent of a
>> JMapPane several times in sequence. Almost always I get the following
>> warning/error message:
>>
>> Jul 11, 2016 8:25:58 AM org.geotools.map.MapContent finalize
>> SCHWERWIEGEND: Call MapContent dispose() to prevent memory leaks
>>
>> Why that? I actually call dispose every time before I set the MapContent.
>> Probably I am updating the JMapPane in a wrong way? Or maybe there it is
>> necessary to do some synchronization?
>>
>> Thanks
>> Julian
>>
>> Here is the small test program to reproduce the warning/error:
>>
>> public class JMapPaneTest extends JFrame {
>>
>> public JMapPane mp;
>>
>> public JMapPaneTest() {
>> mp = new JMapPane();
>> mp.setRenderer(new StreamingRenderer());
>> mp.setMapContent(new MapContent());
>>
>> add(mp);
>> setSize(400,400);
>> setVisible(true);
>> }
>>
>> public void updateMP() {
>> GeometryFactory gf = new GeometryFactory();
>> SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
>> typeBuilder.setName("Points");
>> typeBuilder.add("the_geom",Point.class);
>>
>> SimpleFeatureBuilder featureBuilder = new
>> SimpleFeatureBuilder(typeBuilder.buildFeatureType());
>> Random r = new Random();
>> DefaultFeatureCollection fc = new DefaultFeatureCollection();
>> for( int i = 0; i < 1000; i++ ) {
>> Point p = gf.createPoint(new Coordinate(r.nextDouble(),r.nextDouble()));
>> featureBuilder.set("the_geom", p);
>> fc.add( featureBuilder.buildFeature(""+fc.size()));
>> }
>>
>> MapContent mc = new MapContent();
>> Symbolizer sym = new StyleBuilder().createPointSymbolizer();
>> mc.addLayer(new FeatureLayer(fc, SLD.wrapSymbolizers(sym)));
>> mc.setViewport( new MapViewport(fc.getBounds()));
>> mp.getMapContent().dispose();
>> mp.setMapContent(mc);
>> }
>>
>> public static void main(String[] args) {
>> JMapPaneTest t = new JMapPaneTest();
>> for( int i = 0; i < 1000; i++)
>> t.updateMP();
>> System.exit(1);
>> }
>> }
>>
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
>> Francisco, CA to explore cutting-edge tech and listen to tech luminaries
>> present their vision of the future. This family event has something for
>> everyone, including kids. Get more information and register today.
>> http://sdm.link/attshape
>> _______________________________________________
>> GeoTools-GT2-Users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>>
>>
>
>
> --
> Ian Turton
>
--
Ian Turton
------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users