liuis / leveldb

Automatically exported from code.google.com/p/leveldb
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

memory leak? bytewise = new BytewiseComparatorImpl #194

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
static void InitModule() {
  bytewise = new BytewiseComparatorImpl;
}

WARNING: Visual Leak Detector detected memory leaks!
---------- Block 13900 at 0x0307B730: 4 bytes ----------
  Call Stack:
    c:\vc10\r5xx\leveldb\util\comparator.cc (73): flylinkdc_Debug.exe!leveldb::InitModule + 0x7 bytes
    c:\vc10\r5xx\leveldb\port\port_win.h (122): flylinkdc_Debug.exe!leveldb::port::OnceType::InitOnce + 0x5 bytes
    c:\vc10\r5xx\leveldb\port\port_win.cc (128): flylinkdc_Debug.exe!leveldb::port::InitOnce
    c:\vc10\r5xx\leveldb\util\comparator.cc (77): flylinkdc_Debug.exe!leveldb::BytewiseComparator + 0xF bytes
    c:\vc10\r5xx\leveldb\util\options.cc (25): flylinkdc_Debug.exe!leveldb::Options::Options + 0x28 bytes
    c:\vc10\r5xx\client\cflylinkdbmanager.cpp (2566): flylinkdc_Debug.exe!CFlyLevelDB::CFlyLevelDB + 0x37 bytes

SourceCode

class CFlyLevelDB
{
        leveldb::DB* m_db;
        leveldb::Options      m_options;
        leveldb::ReadOptions  m_readoptions;
        leveldb::ReadOptions  m_iteroptions;
        leveldb::WriteOptions m_writeoptions;

    public:
        CFlyLevelDB();
        ~CFlyLevelDB();

//==============================================================================
==========================
CFlyLevelDB::CFlyLevelDB(): m_db(nullptr)
{
    m_readoptions.verify_checksums = true;
    m_readoptions.fill_cache = true;

    m_iteroptions.verify_checksums = true;
    m_iteroptions.fill_cache = false;

    m_writeoptions.sync      = true;

    m_options.env = leveldb::Env::Default();
    m_options.compression = leveldb::kNoCompression;
    m_options.max_open_files = 10;
    m_options.block_size = 4096;
    m_options.block_cache = leveldb::NewLRUCache(1 * 1024); // 1M
    m_options.paranoid_checks = true;
    m_options.filter_policy = leveldb::NewBloomFilterPolicy(10);
    m_options.create_if_missing = true;
}
CFlyLevelDB::~CFlyLevelDB()
{
    delete m_db;
    delete m_options.filter_policy;
    delete m_options.block_cache;
    delete m_options.env;
}

Original issue reported on code.google.com by Pavel.Pimenov@gmail.com on 26 Jul 2013 at 10:37

GoogleCodeExporter commented 9 years ago
Based on the context, I think it's pretty clear that this is a once-off 
initialisation that makes an allocation that sticks around for the lifetime of 
the process.

Original comment by fullung@gmail.com on 29 Jul 2013 at 12:26

GoogleCodeExporter commented 9 years ago
Thanks for the report. But as mentioned on an earlier comment, this is an 
intentional one-time-initialization "leak".  We intentionally do not attempt to 
clean it up on process exit (think of environments where other threads are 
running and potentially using the global object).

Original comment by san...@google.com on 29 Jul 2013 at 3:33