Strange mapscriptJNI_delete_1layerObj+0xf error killing Tomcat

Arkadi Shishlov arkadi at MEBIUS.LV
Fri Jun 1 09:47:11 EDT 2007


Tamas Szekeres wrote:
 > This error happened when the garbage collector have destroyed a free
 > standing layer object. The C memory of that object have been
 > implicitly destroyed previously upon the destruction of the parent map
 > object.
 >
 > It seems to me that you are possibly using the 'layerObj(mapObj map)'
 > constructor somewhere in your code for creating new layers dynamically
 > and adding to a map. I don't know whether it have handled for java so
 > far, but it is potentially unsafe for SWIG and RFC-24 is dedicated to
 > treat this issue (among other problems).
 >
 > If this statement applies to your code I would suggest to use the
 > layerObj(null) constructor and using insertLayer for adding the layer
 > to the map instead.
 >
 > This issue also applies to the 'classObj(layerObj layer)' and
 > styleObj(classObj parent_class) constructors as well.

This indeed solved my problems too.
After implementing insertClass/Style, using styleObj.getColor().setHex() to set color, and always 
working with a label returned by classObj.getLabel() the application is stable for some time. 
Previously it was crashing every 10 minutes.

I'm also interested what is the semantic of shapeObj.add() and layerObj.addFeature()?
     shapeObj o = new shapeObj(MS_SHAPE_TYPE.MS_SHAPE_POINT.swigValue());
     lineObj n = new lineObj();
     n.add(rulerXY1);
     o.add(n);
     layer.addFeature(o);
Then both shape and line goes out of scope. Is it prone to crash?

These are the helpers for reference:

     protected layerObj getLayer(String name)
     {
         layerObj layer = map.getLayerByName(name);
         if (layer == null) {
             layer = new layerObj(null);
             layer.setName(name);
             map.insertLayer(layer, -1);
             layer = map.getLayerByName(name);
         }
         return layer;
     }

     protected classObj allocClass(layerObj layer)
     {
         int i = layer.insertClass(new classObj(null), -1);
         return layer.getClass(i);
     }

     protected styleObj allocStyle(classObj c)
     {
         int i = c.insertStyle(new styleObj(null), -1);
         return c.getStyle(i);
     }

     protected classObj getFirstClass(layerObj layer)
     {
         if (layer.getNumclasses() > 0)
             return layer.getClass(0);
         return allocClass(layer);

     }

     protected styleObj getFirstStyle(classObj c)
     {
         if (c.getNumstyles() > 0)
             return c.getStyle(0);
         return allocStyle(c);
     }



More information about the mapserver-users mailing list