Skip to content

memory leak when dealing with integer response ? #1

Closed
@thefab

Description

@thefab

With this simple code :

#include <hiredis.h>

int main(void) {
  int i = 0;
  int fd;
  redisConnect(&fd, "127.0.0.1", 6379);
  for (i = 0 ; i < 1000 ; i++) {
    redisReply *coucou = redisCommand(fd, "%s %s", "SCARD", "foo");
    freeReplyObject(coucou);
  }
}

I get a memory leak with valgrind :

valgrind --leak-check=full ./a.out

==22961== 19,000 bytes in 1,000 blocks are definitely lost in loss record 1 of 1
==22961==    at 0x4A0776F: realloc (vg_replace_malloc.c:429)
==22961==    by 0x4C36A7F: sdsMakeRoomFor (sds.c:108)
==22961==    by 0x4C36E88: sdscatlen (sds.c:123)
==22961==    by 0x4C3624B: redisReadLine (hiredis.c:111)
==22961==    by 0x4C36356: redisReadReply (hiredis.c:125)
==22961==    by 0x4C36757: redisCommand (hiredis.c:297)
==22961==    by 0x4006AF: main (toto.c:8)

With a string reply, I don't have this.

Maybe I'm missing something ? Or is there a real memory leak in hiredis ?

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