I am also getting the same error . I reading a shape file and closing the
iterator after reading it. but still  I am getting the same. But i was not
getting the error with geotools 2 version. please help me

code geotools 9

import java.io.File;
import org.geotools.data.shapefile.ShapefileDataStore;
import org.geotools.data.simple.SimpleFeatureCollection;
import org.geotools.data.simple.SimpleFeatureIterator;
import org.geotools.data.simple.SimpleFeatureSource;

public class GeoOpen9
{

private static SimpleFeatureIterator simpleFeatureIterator;
 private static String fileName = "E:\\WorkSpace\\cland\\shape.shp";

 public static boolean openShapeFile() throws Exception
{
 File dataFile = new File(fileName);
dataFile.setReadOnly();
 ShapefileDataStore store = new ShapefileDataStore(dataFile.toURL());
SimpleFeatureSource source = store.getFeatureSource();
 SimpleFeatureCollection featureCollection = source.getFeatures();
 simpleFeatureIterator = featureCollection.features();
return true;
 }
public static  boolean iterate()
 {
while(simpleFeatureIterator.hasNext())
 {
simpleFeatureIterator.next();
 }

 simpleFeatureIterator.close();
return true;
 }
public static void main(String[] args)
 {
try
{
 System.out.println("reading");
GeoOpen9.openShapeFile();
 GeoOpen9.iterate();
System.out.println("Stopped");

}
 catch (Exception e)
{
 e.printStackTrace();
}
 }
}



getools 2.0


//Importing Shapefile packages/classes
//
import java.io.File;

import org.geotools.data.FeatureSource;
import org.geotools.feature.FeatureIterator;
import org.geotools.data.shapefile.ShapefileDataStore;
//
public class GeoOpen2
{
   private static FeatureIterator shapeFeatureIterator;
  private static String fileName = "E:\\WorkSpace\\cland\\shape.shp";
    /**
     * Reads the Data related to the next Plot from various data files
     *
     *  @return TRUE if properly read; Else FALSE
     */
    public static boolean openShapeFile() throws Exception
    {
        File dataFile = new File(fileName);
        ShapefileDataStore store = new ShapefileDataStore(dataFile.toURL());
        FeatureSource source =
store.getFeatureSource(store.getTypeNames()[0]);
        shapeFeatureIterator = source.getFeatures().collection().features();
        return true;
    }

    public static  boolean iterate()
    {
        while(shapeFeatureIterator.hasNext())
        {
            shapeFeatureIterator.next();
        }
        return true;
    }
    public static void main(String[] args)
    {
        try
        {
                  System.out.println("reading");
                GeoOpen2.openShapeFile();
                GeoOpen2.iterate();
                System.out.println("Stopped");
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
   }

}










/*- – - – - – – - – – - – – - – – - – – - – – - – – - – – - – – - – – - -

Please consider your environmental responsibility.
Before printing this e-mail message, ask yourself whether you really need a
hard copy.

Life is what happens to you, while you're busy making other plans

We do not inherit the earth from our ancestors; we borrow it from our
children.
Leave them a living planet reduce your carbon foot print.
------------------------------------------------------------
--------------------------------*/






yours suri chinna


On Tue, Oct 1, 2013 at 7:38 PM, Oehler, Philipp <
philipp.oeh...@isi.fraunhofer.de> wrote:

>  Hi Andrea,****
>
> ** **
>
> thanks for the fast reply!
> I’ve checked everything, but really every iterator in the code is closed
> after usage.
>
> But, I’ve seen now that at the end of error lines stated in my last mail,
> there are further errors:
>
> Okt 01, 2013 4:04:34 PM org.geotools.map.Layer finalize****
>
> SEVERE: Layer dispose not called; possible memory leak****
>
> Okt 01, 2013 4:04:34 PM org.geotools.map.Layer dispose****
>
> SEVERE: Layer preDispose was not called prior to calling dispose****
>
> ** **
>
> (I didn’t notice them before because the huge amount of error lines flush
> the console..)****
>
> Why does this error occur, respectively, how can I dispose layers?
>
> Thanks,****
>
> Philipp ****
>
> ** **
>
> ** **
>
> *Von:* andrea.a...@gmail.com [mailto:andrea.a...@gmail.com] *Im Auftrag
> von *Andrea Aime
> *Gesendet:* Dienstag, 1. Oktober 2013 15:48
> *An:* Oehler, Philipp
> *Cc:* geotools-gt2-users@lists.sourceforge.net
> *Betreff:* Re: [Geotools-gt2-users] Lock on shapefile?!****
>
> ** **
>
> On Tue, Oct 1, 2013 at 3:41 PM, Oehler, Philipp <
> philipp.oeh...@isi.fraunhofer.de> wrote:****
>
>  Hi everyone,****
>
>  ****
>
> my Geotools app to plot country-related data to pngs  is working quite
> well now, but when I create many instances of its base class one after
> another for batch plotting, I’m getting this error after a while (10-20
> instances of ca. 300 to come):****
>
>  ****
>
> Okt 01, 2013 3:02:54 PM org.geotools.data.shapefile.ShpFiles
> logCurrentLockers****
>
> SEVERE: The following locker still has a lock: read on
> file:/D:/workspace_lokal_LAP1328/PowerVisualiser_local/PowerVisualiser_maps/Europa_Mena_Basemap2.shx
> by org.geotools.data.shapefile.shp.IndexFile****
>
> Okt 01, 2013 3:02:54 PM org.geotools.data.shapefile.ShpFiles
> logCurrentLockers****
>
> SEVERE: The following locker still has a lock: read on
> file:/D:/workspace_lokal_LAP1328/PowerVisualiser_local/PowerVisualiser_maps/Europa_Mena_Basemap2.dbf
> by org.geotools.data.shapefile.dbf.IndexedDbaseFileReader****
>
> Okt 01, 2013 3:02:54 PM org.geotools.data.shapefile.ShpFiles
> logCurrentLockers****
>
> SEVERE: The following locker still has a lock: read on
> file:/D:/workspace_lokal_LAP1328/PowerVisualiser_local/PowerVisualiser_maps/Europa_Mena_Basemap2.shp
> by org.geotools.data.shapefile.shp.ShapefileReader****
>
>  ****
>
> over and over. And the rendered pngs contain only some of the countries,
> many are missing.****
>
> Might it be some kind of memory leak?****
>
> I already googled this, and found that it’s necessary to call close(); on
> all opened features; I did this, but the error still remains.****
>
>  ** **
>
> Close on all opened feature iterators. By looking at the above, you still
> have some that are left open****
>
> ** **
>
> Cheers****
>
> Andrea****
>
>  ****
>
> ** **
>
> -- ****
>
> ==****
>
> Our support, Your Success! Visit http://opensdi.geo-solutions.it for more
> information.****
>
> ==****
>
> ** **
>
> Ing. Andrea Aime ****
>
> @geowolf****
>
> Technical Lead****
>
> ** **
>
> GeoSolutions S.A.S.****
>
> Via Poggio alle Viti 1187****
>
> 55054  Massarosa (LU)****
>
> Italy****
>
> phone: +39 0584 962313****
>
> fax: +39 0584 1660272****
>
> mob: +39  339 8844549****
>
> ** **
>
> http://www.geo-solutions.it****
>
> http://twitter.com/geosolutions_it****
>
> ** **
>
> -------------------------------------------------------****
>
>
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
> from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
> _______________________________________________
> GeoTools-GT2-Users mailing list
> GeoTools-GT2-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to