On Wednesday, 6 May 2015 at 18:28:28 UTC, Luís Marques wrote:
On Wednesday, 6 May 2015 at 18:05:57 UTC, deadalnix wrote:
Without going into the details, we had entries in a DB, counting in the millions in the working set. Some of them where hammered heavily, most of them were only needed an handful of time. Problem is, there was no way upfront to know which ones, so we add there entries in a local cache, so we can find the heavily used ones in the cache, and fallback on the DB for the less commonly used ones.

OK, so here the advantages of value vs ref types had to do "only" with allocation issues, and not (also) any advantages in how the values/objects were used per se. So, one could argue that this problem could also be solved through richer memory allocation primitives, without having to have value types?

BTW, given the GC behaviour you described, weak references wouldn't help, would they?

It is not only with allocation issue, but that is certainly a benefit :)

Weak reference would have caused most of the cache to be scrapped at each GC cycle, so that would defeat the purpose of the cache to begin with.

At the end, we ended up using a quite complicated solution involving recycling objects in the cache.

Reply via email to