0xsky / xredis

Redis C++ client, support the data slice storage, support redis cluster, thread-safe,multi-platform,connection pool, read/write separation.
GNU General Public License v3.0
337 stars 153 forks source link

Possible bug in xRedisClient::GetReply() #23

Closed gnyx closed 7 years ago

gnyx commented 7 years ago

Hi, tested the pub/sub parts of your lib and found possible a memory leak in xRedisClient::GetReply().

the reply object is not freed when GetReply() returns. I made a threaded pub/sub application with 200 pub threads and it crashed quite quickly on a low-memory linux system.

When I add the following code snippet it works for hours:

diff --git a/libs/xredis/src/xRedisClient.cpp b/libs/xredis/src/xRedisClient.cpp
index 3e9cfd3..1dec330 100644
--- a/libs/xredis/src/xRedisClient.cpp
+++ b/libs/xredis/src/xRedisClient.cpp
@@ -403,7 +403,7 @@ int xRedisClient::GetReply(xRedisContext* ctx, ReplyData& vData)
             vData.push_back(item);
         }
     }
-
+   RedisPool::FreeReply(reply);
     return ret;
 }

Used the pub/sub implementation from your test implementation. br

0xsky commented 7 years ago

是的,这个地方没有释放,是有BUG的。 谢谢了。

0xsky commented 7 years ago

bug fixed