DapperLib / DapperLib/Dapper

Query cache does not clean and causes memory leak

Open
#1,934 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
18.4k
Forks
3.7k
Avg merge
5h 8m
Merged PRs (30d)
1

Description

In my case i`m executed dynamic generated queries uses Dapper. In production my service uses a lot of memory (~9 GB). I took a memory dump of the process and saw that dapper saved more than a million requests in the query cache. Based on this dump, I calculated the statistics of the number of objects depending on the hitCount https://gist.github.com/denisenko93/9155653319c43b846ace302d6aa3581c

I suggest using MemoryCache as a query cache and making the cache lifetime a dapper setting. Or make the COLLECT_HIT_COUNT_MIN constant available for user change

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files or tests. Start by locating Dapper's query-cache implementation and the COLLECT_HIT_COUNT_MIN constant, then compare the current retention behavior with the proposed MemoryCache and configurable-lifetime alternatives. Done should include a decided eviction policy and evidence that dynamically generated queries no longer cause unbounded cache growth.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
backend, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.