Search code examples
c#.netwinformsmemoryesent

EsentTooManyInstancesException while using Esent databse in windows forms application


We are trying to use Esent database as a replacement to a huge in-memory list to free up memory while the execution of application. But as there are a lot of instances of ESENTDbWrapper(our custom wrapper over Esent.Interop) being created, at some point it throws EsentTooManyInstancesException.

So, what is the maximum no. of simultaneous instances that can be initialized? Or, are we missing any configuration-related stuffs??? Any kind of suggestion is appreciated. Thanks.


Solution

  • The limit for the number of instances is 1024. It sounds as if you're leaking instances.

    But creating an instance is relatively expensive. You should be sharing the same instance, and instead creating multiple sessions for your access.

    The instance is associated with a log file stream, and usually opens up the log files and database exclusively, so you'd get an ACCESS_DENIED error. I'm guessing that you're doing read-only access with your instances, and read-only instances will open the files read-only, with 'allow other readers' to access the files.

    Hope that helps,

    -martin