Boost logo

Boost :

Subject: [boost] [serialization] Memoryleak in void_caster::recursive_register
From: Runar Undheim (R.Undheim_at_[hidden])
Date: 2009-06-30 02:35:51


// implementation of void caster base class
BOOST_SERIALIZATION_DECL(void)
void_caster::recursive_register(bool includes_virtual_base) const {
    void_cast_detail::set_type & s
        = void_cast_detail::void_caster_registry::get_mutable_instance();

    s.insert(this);

    // generate all implied void_casts.

    void_cast_detail::set_type::const_iterator it;
    for(it = s.begin(); it != s.end(); ++it){
        if(m_derived == (*it)->m_base)
            new void_caster_shortcut(
                (*it)->m_derived,
                m_base,
                m_difference + (*it)->m_difference,
                includes_virtual_base
            );
        if((*it)->m_derived == m_base)
            new void_caster_shortcut(
                m_derived,
                (*it)->m_base,
                m_difference + (*it)->m_difference,
                includes_virtual_base
            );
    }
}

The new void_caster_shortcut in void_caster::recursive_register give
memory leak. The leak is only at startup of program, so it doesn't eat
any memory while the program is running. But it makes it difficult to
find other memory leaks when the program contain several leaks you don't
care about.

- Runar


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk