On Wed, Aug 3, 2011 at 5:45 AM, Gerson Galang <[email protected]> wrote: > Hi guys, > > I've been using geotools for more than a month now but only started > noticing that it performs slowly after running consecutive getFeatures > requests given a specified bounding box as a filter parameter. > > I have a web application that uses geotools to find locations in a Postgis > server I have running on the same machine. The webapp provides users an > option to dig into a particular location they want to investigate on. The > webapp has a drop down menu of States, Local Government Authorities > (LGAs), and Suburbs. When a user picks a State, the LGA dropdown menu gets > populated by LGAs found within the state. Same thing happens when the user > picks an LGA which then populates the Suburb dropdown menu. The problem > starts to happen when I continually change the selected items in the State > and/or LGA dropdown menus. I get an immediate response for the first > query. The succeeding queries will usually take about 5-10 minutes before > seeing a response. > > These are the only two steps I go through to populate the Suburb dropdown > menu.. > 1. Get the bounding box for the given LGA > 2. Get the locations (features) within the given bounding box > > We had a look at the memory being used by the application and noticed that > the heap gets filled by a lot of char arrays (about 350MB of them) used by > geotools when running the "getFeatures for the given bounding box" > request. Forcing a garbage collection to happen when I see that my query > waiting for a response makes the server respond immediately. > > The way I instantiate the datastore is by creating a map with HOST, > DATABASE, PORT, USER, PASSWD, DBTYPE, and VALIDATECONN specified as a > parameter to the DataStoreFinder. > > Can you see if I'm doing anything wrong? Do you have any advice on how I > can make my code perform faster?
Use GeoServer and be done with it? ;-) Just kidding, but in fact GeoServer uses the GeoTools api and we have instances running for a lot longer that do no exhibit the same behavior. The first thing I'm wondering is if you're closing all the feature iterators: each one of them holds onto a connection, if you don't close them the connection will be released only when the feature iterators gets garbage collected. Goes without saying that you should always use FeatureIterator and forget about plain iterators. If you want help locating the bits of code that got the iterators without closing them set the system variable gt2.jdbc.trace to true and you'll get a stack trace telling you were the iterator was allocated from Cheers Andrea -- ------------------------------------------------------- Ing. Andrea Aime GeoSolutions S.A.S. Tech lead Via Poggio alle Viti 1187 55054 Massarosa (LU) Italy phone: +39 0584 962313 fax: +39 0584 962313 http://www.geo-solutions.it http://geo-solutions.blogspot.com/ http://www.youtube.com/user/GeoSolutionsIT http://www.linkedin.com/in/andreaaime http://twitter.com/geowolf ------------------------------------------------------- ------------------------------------------------------------------------------ BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA The must-attend event for mobile developers. Connect with experts. Get tools for creating Super Apps. See the latest technologies. Sessions, hands-on labs, demos & much more. Register early & save! http://p.sf.net/sfu/rim-blackberry-1 _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
