mapscript jvm crash on removeLayer
Umberto Nicoletti
umberto.nicoletti at GMAIL.COM
Fri Sep 8 05:48:59 PDT 2006
Unfortunately Mapscript suffers from a few memory management issues
which will almost surely kill the Java VM.
In these cases the only approach is to work around them. I suggest you
try to disable (set status to OFF) the first layer instead of deleting
it. This is safe and should work in most cases.
Alternatively you could try to clone the feats before adding them to
the second layer newannLayer.addFeature(shape2.clone());, but you
could still have problems.
In any case please open a bug at http://mapserver.gis.umn.edu/bugs/ so
that we can solve this issue in the future. Make sure you attach the
error log generated by java to the bug report.
Umberto
On 9/8/06, mikiet <mike.talbutt at dottedeyes.com> wrote:
> 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);
> --
> View this message in context: http://www.nabble.com/mapscript-jvm-crash-on-removeLayer-tf2238325.html#a6206628
> Sent from the Mapserver - User forum at Nabble.com.
>
More information about the MapServer-users
mailing list