I'm using MIC for my LRU cache in server, it has replaced list/map LRU since I was suspecting that this is what caused some unexplained memory footprint. Memory leaks are out of picture, at least no tool has found any leak as well as code inspection. Since I've started to use MIC the picture improved (that the only proof of memory fragmentation) but not enough. We are talking about several Gb of cache, millions of records being ejected from it on daily basis. After two to three weeks the problem becomes clear to see - if I empty the cache the process still holds unexplained 2-3Gb of memory.
My container is quite simple:
typedef std::pair<Key, T> Element;
typedef mic::multi_index_container<
Element,
mic::indexed_by<mic::sequenced<mic::tag<struct Seq>>,
mic::hashed_unique<mic::tag<struct Hash>, mic::member<Element, const Key, &Element::first>>>>
item_list;
it uses erase
and push_front
to insert new entry (or overwrite old one) and then if needed ejects element from tail. The question is is it worth trying to use replace
and relocate
instead of push_front
?
UPDATE001: Ok, the new version is up and running, I see that realocate significantly improved the situation, the memory footprint after 3 weeks was ~1/1.5 Gb less than footprint on machines without the change. Now it deployed on all machines worldwide. As second stage there are numerous changes to the cache invalidation machinery. Less ejections and re-insertions should improve the situation too (in case it is really memory fragmentation)