5

We are using a multimap for quick value/index lookups, declared like this

typedef double Numerical;
std::multimap<Numerical, Int32> SortableRowIndex;

And we fill it up with pairs, using

SortableRowIndex.insert(std::pair<Numerical, Int32>(GetSortable(i), i));

The function GetSortable() always returns a double. And this works fine. Iterating through the values works fine too. But then comes the weird part... sometimes when we try to clear the data...

SortableRowIndex.clear();

... it goes into some kind of loop and stalls/races, hogging the used core of the CPU at 100%.

The clear method seems to be inherited from xtree (system file) and there are only a coupld of rows inside it:

    void clear() _NOEXCEPT
        {   // erase all
 #if _ITERATOR_DEBUG_LEVEL == 2
        this->_Orphan_ptr(*this, 0);
 #endif /* _ITERATOR_DEBUG_LEVEL == 2 */

        _Erase(_Root());
        _Root() = this->_Myhead;
        _Lmost() = this->_Myhead;
        _Rmost() = this->_Myhead;
        this->_Mysize = 0;
        }

For some reason, my Visual Studio 2013 won't let me step into this method when debugging... and I can't, for the life of me figure out what the problem is!

Any help will be ridiculously appreciated!

braX
  • 11,506
  • 5
  • 20
  • 33

1 Answers1

3

As it turns out, it's not really stalling, but clearing a multimap through Visual Studio's debugger is REALLY SLOW. I noticed that the memory was getting released slooowly and let it run for a couple of minutes and then it was finally done. Running the application outside of Visual Studio made the .clear() calls drop down to < 1s, even for millions of pairs.

So, heads up if you are clearing huge multimaps while running in debug mode in visual studio. It's sloooooow.