You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Use Valgrind to analsis memory leak.
It report possible lost in location
==2611148== 2,028 bytes in 2 blocks are possibly lost in loss record 749 of 764
==2611148== at 0x484DCD3: realloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==2611148== by 0x4863B4F: hi_realloc (alloc.h:71)
==2611148== by 0x4863B4F: sdsMakeRoomFor (sds.c:226)
==2611148== by 0x486436B: sdscatlen (sds.c:384)
==2611148== by 0x4869C1C: redisReaderFeed (read.c:724)
==2611148== by 0x4862D21: redisBufferRead (hiredis.c:985)
==2611148== by 0x48630AF: redisGetReply (hiredis.c:1081)
==2611148== by 0x48B64C6: sw::redis::Connection::recv(bool) (in /usr/local/lib/libredis++.so.1.3.14)
==2611148== by 0x48CBDBC: std::enable_if<!std::is_convertible<void (*)(sw::redis::Connection&, std::basic_string_view<char, std::char_traits<char> > const&), std::basic_string_view<char, std::char_traits<char> > >::value, std::unique_ptr<redisReply, sw::redis::ReplyDeleter> >::type sw::redis::Redis::command<void (*)(sw::redis::Connection&, std::basic_string_view<char, std::char_traits<char> > const&), std::basic_string_view<char, std::char_traits<char> > const&>(void (*)(sw::redis::Connection&, std::basic_string_view<char, std::char_traits<char> > const&), std::basic_string_view<char, std::char_traits<char> > const&) (in /usr/local/lib/libredis++.so.1.3.14)
==2611148== by 0x48C245F: sw::redis::Redis::get[abi:cxx11](std::basic_string_view<char, std::char_traits<char> > const&) (in /usr/local/lib/libredis++.so.1.3.14)
To Reproduce
Minimal code to reproduce the bug.
sw::redis::ConnectionPoolOptionspoolOptions;
poolOptions.size=100;
poolOptions.wait_timeout=std::chrono::milliseconds(100);
poolOptions.connection_lifetime=std::chrono::minutes(10); // Max lifetime of a connection// Redis URI schema: tcp://[[username:]password@]host[:port][/db]
auto uri=sw::redis::Uri("redis://default:redisadmin123@localhost:6379/1");sw::redis::Redisredis (uri.connection_options(), poolOptions);
// sample codeintCheckStatus<T>::match(shared_ptr<T>&item) {
// check key's value in redis dbstringkey=fmt::format(":1:{0}/mi", item->m_mac);
auto val=redis->get(key);
if (val){
item->m_isok=*val=="1" ? true: false;
}
else{
item->m_isok= false;
}
}
...
Expected behavior
A clear and concise description of what you expected to happen.
Environment:
OS: [e.g. ubuntu]
Compiler: 13.1.0
hiredis version:1.2.0
redis-plus-plus version: 1.3.14
Additional context
redis-plus-plus build with cmake .. -DREDIS_PLUS_PLUS_CXX_STANDARD=20
-- redis-plus-plus version: 1.3.14
-- The CXX compiler identification is GNU 13.1.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- redis-plus-plus build type: Release
-- redis-plus-plus build with CXX standard: c++20
-- redis-plus-plus TLS support: OFF
-- redis-plus-plus check hiredis features
-- Looking for redisEnableKeepAliveWithInterval
-- Looking for redisEnableKeepAliveWithInterval - found
-- redis-plus-plus build static library: ON
-- redis-plus-plus build static library with position independent code: ON
-- redis-plus-plus build shared library: ON
-- redis-plus-plus build test: ON
-- The C compiler identification is GNU 13.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Debian package name: .deb
-- Configuring done
-- Generating done
-- Build files have been written to: /home/xxxx/redis-plus-plus/build
Is it a memory leak?
The text was updated successfully, but these errors were encountered:
Hoohaha
changed the title
[BUG] Possible lost in sw::redis::Redis::get
[BUG] Memory Leak: Possible lost in sw::redis::Redis::get?
Nov 28, 2024
Sorry, but I cannot reproduce your problem with the following code (since your code cannot compile, I modified it):
#include <iostream>
#include <string>
#include <sw/redis++/redis++.h>
using namespace std;
int main() {
sw::redis::ConnectionPoolOptions poolOptions;
poolOptions.size = 100;
poolOptions.wait_timeout = std::chrono::milliseconds(100);
poolOptions.connection_lifetime = std::chrono::minutes(10); // Max lifetime of a connection
// Redis URI schema: tcp://[[username:]password@]host[:port][/db]
auto uri = sw::redis::Uri("redis://localhost:6379/1");
sw::redis::Redis redis (uri.connection_options(), poolOptions);
string key = "test";
auto val = redis.get(key);
if (val){
cout << *val << endl;
} else {
cout << "not found" << endl;
}
return 0;
}
Can you try this code with your installation? Or give me code snippet that can be compiled without any third party dependency to reproduce the problem?
By the way, redis.Uri is internal implementation, you'd better not call it in your application code. You can use the following code to achieve your goal:
Describe the bug
Use Valgrind to analsis memory leak.
It report possible lost in location
To Reproduce
Minimal code to reproduce the bug.
Expected behavior
A clear and concise description of what you expected to happen.
Environment:
Additional context
redis-plus-plus build with
cmake .. -DREDIS_PLUS_PLUS_CXX_STANDARD=20
Is it a memory leak?
The text was updated successfully, but these errors were encountered: