mapNextTx entries comprise about 15% of application memory usage once the mempool warms up; most of this space is taken by the key type, which contains a uint256. The same uint256 is accessible from the map’s value type.
setSpends represents the information as a set of CSpendRefs. A CSpendRef is, logically, a reference to a COutPoint; the COutPoint may be either “free” (as in the case of setSpends.find(COutPoint(…))), or in an element of the vin of a CTransaction (as in all the values inserted into setSpend). If the COutPoint is associated with a spending CTransaction, the CSpendRef is also capable of providing access to the corresponding transaction.
[This object bimodality is necessary because lookup on a set requires constructing an object of the set’s key type, an inconvenience corrected in C++14.]
Saves about 10% of total memory usage (an entry in mapNextTx is 48 bytes; an entry in setSpends in 16 bytes). Since the mempool is DynamicUsage-regulated, this will translate to a larger mempool in the same amount of space.
(Supersedes #7991, which addressed the same issue less efficiently)