Why Request Caching keeps thousands of RavenJ.. objects in memory, when only a couple of big documents are loaded?

41 views
Skip to first unread message

Plamen Boudinov

unread,
Apr 11, 2017, 10:52:53 AM4/11/17
to RavenDB - 2nd generation document database
At application start we Load<> and store static references to couple of big POCO objects (one is 8mb the other 3mb).
DocumentStore a singleton.
We dispose sessions.

If we do not disable request caching by means of 'store.Conventions.ShouldCacheRequest', this is what our memory dump looks like (attached screenshot) - lots of thousands of RavenJToken and RavenJValue objects.
If we setup ShouldCacheRequest to false, there are no such objects at all.

It actually gives us some terrible performance problems in Azure, when our Isolated computing has high memory usage, as GC is wakling over these thousand of RavenJ objects.
Capture.PNG

Wallace Turner

unread,
Apr 11, 2017, 5:52:40 PM4/11/17
to RavenDB - 2nd generation document database
Plamen, I have run into a similar issue see this recent thread [1]

I have worked around this by utilizing query.Customize(x=>x.NoCaching( ) ) for the queries i do not want cached.

also after you setup your db you can change the size of the cache:
store.Initialize();
store.MaxNumberOfCachedRequests = 128;  //default is 2048

Wal

Oren Eini (Ayende Rahien)

unread,
Apr 12, 2017, 3:26:00 AM4/12/17
to ravendb
This is because every request with etag is cached, this can happen if you have a lot of different queries, or if you are querying with time.

Also, see Wallace information on how to reduce this.

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Plamen Boudinov

unread,
Apr 13, 2017, 3:33:15 AM4/13/17
to RavenDB - 2nd generation document database
Thanks for the answers, i have worked around it already disabling cache.
This question is more about request cache implementation - why caching 2 big poco objects produces 200k RavenJValue + 30k RavenJToken objects in memory?
Isn't this a 'Dangerous by default' paradigm?

Oren Eini (Ayende Rahien)

unread,
Apr 14, 2017, 5:10:33 AM4/14/17
to ravendb
That is because we store the parsed json in the cache, and you are likely looking at an object that is actually composed of MANY small pieces.
In 4.0, we are just storing the chunk of memory directly, so not a lot of objects.

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
Reply all
Reply to author
Forward
0 new messages