Closed GoogleCodeExporter closed 9 years ago
local_value.flags = DB_DBT_USERMEM;
local_value.size = store_value.size() + 1;
->
local_value.flags = DB_DBT_USERMEM;
local_value.ulen = store_value.size() + 1;
is the same report
Original comment by owandyw...@gmail.com
on 29 Apr 2010 at 7:23
I'm not sure I understand your bug report. When I try running your program
above,
when the 'free' line is commented out, I get a leak error, and when the 'free'
line is
not commented out, I get no leak error. That's exactly what I would expect
when using
DB_DBT_MALLOC. Is that not what you're seeing?
I can't evaluate your second example, since it's just a snippet. If you can
provide a
full program that demonstrates the problem, I could try running it as well.
Original comment by csilv...@gmail.com
on 30 Apr 2010 at 1:18
Many thanks for your reply. You are right, the DB_DBT_MALLOC ask the users to
free it them-selfs.
About the second example, my style perhaps not good. I found a similar example
db-
4.8.26/examples_c/bench_001.c. There is a function 'fill', and the following
snippet
197 memset(&key, 0, sizeof(DBT));
198 memset(&data, 0, sizeof(DBT));
199 key.data = &i;
200 key.size = sizeof(i);
201 data.data = data_val = malloc(datalen);
202 memcpy(data_val->str, "0123456789012345678901234567890123456789",
203 datalen - sizeof(data_val->id));
204 data.size = datalen;
205 data.flags = DB_DBT_USERMEM;
There is a malloc on line201 but no matching free. I try out that there is
memory
leak without free. Is the example without free a bug? There is no related
information
in the manual, wish your help!
Original comment by owandyw...@gmail.com
on 30 Apr 2010 at 3:51
If I understand you right, you're saying that you malloc the memory but don't
free it,
and the heap-checker is detecting that as a memory leak. That seems exactly
right to
me. What would you expect, that's different?
Original comment by csilv...@gmail.com
on 30 Apr 2010 at 4:06
Yes. I encountered two problems as post before. Firstly, when i using
DB_DBT_MALLOC,
i think bdb should free itself , its should not leave free to user. Now this
problem
is clear though i think this style is not good. Secondly, i think before
db->put i
malloc a buffer and free it is proper. But, i found the official example
examples_c/bench_001.c malloc without free. When i followed the example and
found
memory leak. So i'm not sure is there something wrong with the bdb example or
with
heap-checker.
Original comment by owandyw...@gmail.com
on 30 Apr 2010 at 4:41
I'd say the documentation is wrong: nothing I know about bdb says it frees
memory that
you allocate. I don't see any bugs here.
Original comment by csilv...@gmail.com
on 30 Apr 2010 at 5:24
Original issue reported on code.google.com by
owandyw...@gmail.com
on 29 Apr 2010 at 6:57