Need to dispose a Geodatabase always?

689
0
11-30-2016 12:30 PM
ForrestKaye
New Contributor III

The documentation states that :

"public void dispose () -- Disposes the geodatabase. This method must be called when closing an application (or when otherwise finished with the geodatabase) to release resources which use the Geodatabase class."

 

So do you always need to dispose a temporary geodatabase created for some reason within the app?  Would there be issues if I did not dispose the tempGDB at all?  What about if I only disposed the tempGDB on the final  tempGDB, ignoring the ones created during the loop?

Is there a memory leak if the geodatabase is never disposed?

Ex: 

private void someFunciton(){
   Geodatabase tempGDB;
   for (String gdbPath: gdbArray) {  //gdbArray is just an array of strings that contains paths to GDB's
      try {
         tempGDB = new Geodatabase(gdbPath);
         //does something with tempGDB
         //...finds all layers...etc.
         tempGDB.dispose();
      }catch(Exception e){
      }
   }
}

Thanks!

0 Kudos
0 Replies