Question

I see from every example for the appengine datastore that it is important to surround query executions, etc with try{}finally{} blocks to ensure that queries are always closed.

What happens if a query or persistence manager isn't closed, but goes out of scope? Could an entity ever be made permanently inaccessible?

Was it helpful?

Solution

Closing a PersistenceManager might release it to the pool of available PersistenceManagers, or might be garbage collected, at the option of the JDO implementation.

My interpretation of that is that if you let a PersistanceManager go out of scope without closing it then it will be garbage collected and will not be released to the pool of available PersistenceManagers, which may cause additional overhead when calling PersistenceManagerFactory.getPersistenceManager() if there are no more available PersistenceManagers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top