System.OutOfMemoryException and EsentVersionStoreOutOfMemoryException

597 views
Skip to first unread message

Tareq Perez

unread,
Jul 17, 2012, 2:56:59 PM7/17/12
to rav...@googlegroups.com
I get both of these exceptions after a certain amount of time that my application is running.

The batch upload is 30 documents and on average 1 MB per document.

I dispose and re-initialize the session after 5 requests.

During some of the SaveChanges I get:

System.OutOfMemoryException

and 

2012-07-17 14:52:00.8426      Error 6 Url: "/docs/Raven/Hilo/MachineDays"

Microsoft.Isam.Esent.Interop.EsentVersionStoreOutOfMemoryException: Version store out of memory (cleanup already attempted)
   at Microsoft.Isam.Esent.Interop.Update..ctor(JET_SESID sesid, JET_TABLEID tableid, JET_prep prep) in C:\Work\ravendb\SharedLibs\Sources\managedesent-61618\EsentInterop\Update.cs:line 44
   at Raven.Storage.Esent.StorageActions.DocumentStorageActions.AddDocument(String key, Nullable`1 etag, RavenJObject data, RavenJObject metadata) in c:\Builds\RavenDB-Stable\Raven.Storage.Esent\StorageActions\Documents.cs:line 302
   at Raven.Database.DocumentDatabase.<>c__DisplayClass37.<Put>b__30(IStorageActionsAccessor actions) in c:\Builds\RavenDB-Stable\Raven.Database\DocumentDatabase.cs:line 480
   at Raven.Storage.Esent.TransactionalStorage.ExecuteBatch(Action`1 action) in c:\Builds\RavenDB-Stable\Raven.Storage.Esent\TransactionalStorage.cs:line 376
   at Raven.Storage.Esent.TransactionalStorage.Batch(Action`1 action) in c:\Builds\RavenDB-Stable\Raven.Storage.Esent\TransactionalStorage.cs:line 364
   at Raven.Database.DocumentDatabase.Put(String key, Nullable`1 etag, RavenJObject document, RavenJObject metadata, TransactionInformation transactionInformation) in c:\Builds\RavenDB-Stable\Raven.Database\DocumentDatabase.cs:line 468
   at Raven.Database.Server.Responders.Document.Put(IHttpContext context, String docId) in c:\Builds\RavenDB-Stable\Raven.Database\Server\Responders\Document.cs:line 154
   at Raven.Database.Server.Responders.Document.Respond(IHttpContext context) in c:\Builds\RavenDB-Stable\Raven.Database\Server\Responders\Document.cs:line 49
   at Raven.Database.Server.HttpServer.DispatchRequest(IHttpContext ctx) in c:\Builds\RavenDB-Stable\Raven.Database\Server\HttpServer.cs:line 550
   at Raven.Database.Server.HttpServer.HandleActualRequest(IHttpContext ctx) in c:\Builds\RavenDB-Stable\Raven.Database\Server\HttpServer.cs:line 316

Matt Warren

unread,
Jul 17, 2012, 4:15:52 PM7/17/12
to rav...@googlegroups.com
Try doubling the value of the settings below to 256MB:

Raven/Esent/MaxVerPages
The maximum size of version store (in memory modified data) available. The value is in megabytes.
Default: 128

See http://ravendb.net/docs/server/administration/configuration

Also what build are you using, the latest build has a lot of improvements in this area.

Tareq Perez

unread,
Jul 17, 2012, 4:26:18 PM7/17/12
to rav...@googlegroups.com
Currently on build #960 which I'm pretty sure is the newest version.

I just added the config statement, just to make sure

<configuration>
<appSettings>
<add key="Raven/DataDir" value="~\Data"/>
<add key="Raven/AnonymousAccess" value="Get"/>
<add key="Raven/Esent/MaxVerPages" value="256"/>
</appSettings>
<system.webServer>
<handlers>
<add name="All" path="*" verb="*" type="Raven.Web.ForwardToRavenRespondersFactory, Raven.Web"/>
</handlers>
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
</modules>
</system.webServer>
<runtime>
<loadFromRemoteSources enabled="true"/>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Analyzers"/>
</assemblyBinding>
</runtime>
</configuration>


this is what it should look like right?

Matt Warren

unread,
Jul 17, 2012, 4:41:06 PM7/17/12
to rav...@googlegroups.com
That settings look okay.

I *think* the changes are only in the latest unstable branch, i.e. builds > 2000 (http://builds.hibernatingrhinos.com/Builds/RavenDB-Unstable)

Oren Eini (Ayende Rahien)

unread,
Jul 17, 2012, 6:23:39 PM7/17/12
to rav...@googlegroups.com
Can you create a repro?
Are you running in 32 or 64 bits?

Tareq Perez

unread,
Jul 18, 2012, 11:42:34 AM7/18/12
to rav...@googlegroups.com
I lowered the documents per request to 15 and the requests per session object to 5, that made the application run longer
than previously using 30 docs per request and 10 requests per session.

I'm on a 64 bit machine.

Oren Eini (Ayende Rahien)

unread,
Jul 18, 2012, 12:13:12 PM7/18/12
to rav...@googlegroups.com
Use one request per session

Tareq Perez

unread,
Jul 18, 2012, 2:57:06 PM7/18/12
to rav...@googlegroups.com
It lasted a little longer this time, but still giving me that exception eventually.

Oren Eini (Ayende Rahien)

unread,
Jul 18, 2012, 3:15:29 PM7/18/12
to rav...@googlegroups.com
Can you create a repro?

Tareq Perez

unread,
Jul 18, 2012, 3:17:51 PM7/18/12
to rav...@googlegroups.com
Restarting the program doesn't suppress the exceptions either. I have to restart the RavenDB service in order to run my application again.

Tareq Perez

unread,
Jul 19, 2012, 1:22:49 AM7/19/12
to rav...@googlegroups.com
I tried, unfortunately I couldn't get it to replicate with a quick program.

Matt Warren

unread,
Jul 19, 2012, 4:34:57 AM7/19/12
to rav...@googlegroups.com
Is there a chance that your process is actually running as a 32-bit process, even though you have a 64-bit CPU. You can tell by looking at the process in Process Explorer (http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx), under the "Image Type" column.

Tareq Perez

unread,
Jul 19, 2012, 8:45:33 AM7/19/12
to rav...@googlegroups.com
You are correct, I am developing on a 32-bit machine and running it as a windows service on a 64-bit server box. I didn't realize that this would be a problem. Do you think that is what is causing the error then?

Matt Warren

unread,
Jul 19, 2012, 8:48:04 AM7/19/12
to rav...@googlegroups.com
It's it's a 32-bit process is only has 1.5GB of memory (per-process) available, so it's going to run out of memory much sooner.

RavenDB can run in 32-bit mode, but it's not recommended. You have to tune a few settings yourself to make it work though.

Tareq Perez

unread,
Jul 19, 2012, 8:51:10 AM7/19/12
to rav...@googlegroups.com
so my options are

a) change my application to a 64-bit process

b) configure RavenDB to run in 32-bit mode

What settings do I have to change to make 32-bit mode work?

Matt Warren

unread,
Jul 19, 2012, 8:56:02 AM7/19/12
to rav...@googlegroups.com
For b) see  http://ravendb.net/docs/faq/low-memory-footprint and http://ravendb.net/docs/server/administration/configuration, but honestly it's easier to make it run as a 64-bit process if you can.

Tareq Perez

unread,
Jul 19, 2012, 8:58:52 AM7/19/12
to rav...@googlegroups.com
Yea, If i can get approved for a 64 bit machine at work, I will. Unfortunately with a 32-bit version of visual studio, I can't easily convert my application to 64-bit.

If the new server configuration doesn't work, I'm sure I'll be able to convince them. Thank you for your help!

Matt Warren

unread,
Jul 19, 2012, 9:09:06 AM7/19/12
to rav...@googlegroups.com
You should be able to do that using "Any CPU", if you app is fully managed, see  http://stackoverflow.com/questions/128294/what-do-i-need-in-order-to-create-64-bit-net-applications/128310#128310

Tareq Perez

unread,
Jul 19, 2012, 1:45:52 PM7/19/12
to rav...@googlegroups.com
Thank you so much! I got it changed and it's working now.

Oren Eini (Ayende Rahien)

unread,
Jul 19, 2012, 6:16:51 PM7/19/12
to rav...@googlegroups.com
Great

Chris Marisic

unread,
Jul 20, 2012, 9:42:12 AM7/20/12
to rav...@googlegroups.com
It is 2012, no developer should be using a 32bit machine.
Reply all
Reply to author
Forward
0 new messages