values created during inserts that are
unreferenced are not deleted because evict()
does not delete values unless set.size() > lru_target_size.
For example, this condition is not met if the number
of entries in the intrusive_lru are less than or
equal to lru_target_size at the time of the
intrusive_lru's destruction.
Memory leaks due to the above scenario can be
reproduced if this commit is removed and
unittest_intrusive_lru is run under valgrind.
ex:
valgrind --tool=memcheck --leak-check=yes ./bin/unittest_intrusive_lru
Signed-off-by: Ali Maredia <amaredia@redhat.com>
(cherry picked from commit
abd84ad770ffe10771aeae060514a42e76150569)
evict();
}
+ ~intrusive_lru() {
+ set_target_size(0);
+ }
+
friend void intrusive_ptr_add_ref<>(intrusive_lru_base<Config> *);
friend void intrusive_ptr_release<>(intrusive_lru_base<Config> *);
};