Skip to content

Memory leak in ScriptEvaluate(string) #617

@Funbit

Description

@Funbit

Hello,
First of all, I want to say that I've been using StackExchange.Redis package for a couple of years without any problems. However, recently, I started experiencing strange memory leaks. Usually, I always used prepared LUA scripts (via LuaScript.Prepare), but after some point I had to introduce some manually generated LUA scripts. The new code I'm using looks like this:

var builder = new StringBuilder("redis.call('HMSET',");
builder.Append(...); 
// build some script here and then run it as string:
_connectionMultiplexer.GetDatabase().ScriptEvaluate(builder.ToString());

After several days of running, the server memory goes above 1GB (usually it stayed around 200MB). I dumped the process a couple of times and result is the same: there are many strings (500000+) with reference count = 1 in a Hashtable bucket. I'm not sure why it's there and why it cannot be freed (the script is not prepared, so it shouldn't be cached, etc).

I have attached a couple of screenshots (from MemoScope 0.9.999).

Is there any way to fix/avoid such behavior?

PS. If you need more information please let me know.
PPS. I'm using the latest version of the NuGet package (1.2.1).

Total string count:
capture1
This is how strings look like (builder.ToString() output):
capture
Here is the reference map for each string:
capture2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions