AnsweredAssumed Answered

Need to dispose a Geodatabase always?

Question asked by forrestkaye on Nov 30, 2016

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!

Outcomes