basho / eleveldb

Erlang LevelDB API
262 stars 176 forks source link

c_src/eleveldb.cc:652]: (error) Memory leak: batch [JIRA: RIAK-2734] #212

Open dcb314 opened 8 years ago

dcb314 commented 8 years ago

Source code is

// Construct a write batch:
leveldb::WriteBatch* batch = new leveldb::WriteBatch;

// Seed the batch's data:
ERL_NIF_TERM result = fold(env, argv[2], write_batch_item, *batch);
if(eleveldb::ATOM_OK != result)
{
    return send_reply(env, caller_ref,
                      enif_make_tuple3(env, eleveldb::ATOM_ERROR, caller_ref,
                                       enif_make_tuple2(env, eleveldb::ATOM_BAD_WRITE_ACTION,
                                                        result)));
}   // if
matthewvon commented 8 years ago

Agreed.

larshesel commented 7 years ago

The leak would be due to batch never being freed?

matthewvon commented 7 years ago

No clue why this was never closed. Fix is present in code. See

https://github.com/basho/eleveldb/commit/d595ae325f2a2a078aca257ee6742ea83a488d27

Batch is now freed in error handling.

larshesel commented 7 years ago

oh, cool - I hadn't seen that, only checked this bug was present in our version. Thanks!