mapscript jvm crash on removeLayer

listuser HH listuser at HERZSYS.DE
Fri Sep 8 07:37:19 EDT 2006


Hi,

you can try the following:

1. make a temporary mapObj (new..  or map.clone)
2. make a temporary layer and add the annotations
3. insert the layer with annotations in the mapObj
4. do something (e.g. draw)
5. call delete on this layer
6. call delete on the temp mapObj

Regards
Norbert

mikiet schrieb:
> Hi, 
>
> I am using java mapscript in an application. I have the requirement to add
> annotations to an inline layer, and remove annotations from an inline layer.
>
> I beleive removing annotations from an inline layer is not availble in
> mapscript so as a work around I wanted to create a new layer with all the
> features from my inline layer except the one I wanted to remove, then remove
> the old layer (Hope that makes sense !).
>
> Unfortunatly when I try and remove my old layer from the map the jvm crashes
> taking down the tomcat process.
>
> >From the entry 'Java VM Crashes using the Mapscript API' I can see a few
> people have had simillar problems and its being put down to a garbage
> collection problems in the jvm. The post states you should call the delete
> method on a classObj when it is no longer used, I have tried this but its
> not got rid of the problem. Can anyone point me in the right direction
> please
>
> My code is below...
>
> 		layerObj annLayer = mapobject.getLayerByName(sLayerName);
> 		layerObj newannLayer = new layerObj(mapobject);
> 	        int featureCounter = 0;
> 	        while (featureCounter < annLayer.getNumFeatures()){
> 	            shapeObj shape2 = annLayer.getFeature( featureCounter ,-1); 
> 	        	if (shape2.getValue(1).equals(sName)){
> 	        		System.out.println("retreived shape index - " +
> shape2.getIndex());
> 	                        System.out.println("retreived shape - " +
> shape2.getValue(1));
> 	        	}
> 	        	else{
> 	        		System.out.println("adding feature to new layer " +
> shape2.getValue(1));
> 	        		newannLayer.addFeature(shape2);
> 	        	}
> 	        	featureCounter++;
> 	        }
> 	        annLayer.getClass(0).getStyle(0).delete();
> 	        annLayer.getClass(0).delete();
> 	        annLayer.delete();
> 	        mapobject.removeLayer(annLayer.getIndex());
> 	        newannLayer.setName(sLayerName);
>   



More information about the mapserver-users mailing list