// The CommitLimiter encapsulates a limit we may want to impose on how much // memory can be committed. This is a matter of separation of concerns: // // In metaspace, we have two limits to committing memory: the absolute limit, // MaxMetaspaceSize; and the GC threshold. In both cases an allocation should // fail if it would require committing memory and hit one of these limits. // // However, the actual Metaspace allocator is a generic one and this // GC- and classloading specific logic should be kept separate. Therefore // it is hidden inside this interface. // // This allows us to: // - more easily write tests for metaspace, by providing a different implementation // of the commit limiter, thus keeping test logic separate from VM state. // - (potentially) use the metaspace for things other than class metadata, // where different commit rules would apply. // class CommitLimiter : public CHeapObj<mtMetaspace> {
// Counts total words committed for metaspace
SizeCounter _cnt;
// Purely for testing purposes: cap, in words. const size_t _cap;
public:
// Create a commit limiter. This is only useful for testing, with a cap != 0, // since normal code should use the global commit limiter. // If cap != 0 (word size), the cap replaces the internal logic of limiting.
CommitLimiter(size_t cap = 0) : _cnt(), _cap(cap) {}
// Returns the size, in words, by which we may expand the metaspace committed area without: // - _cap == 0: hitting GC threshold or the MaxMetaspaceSize // - _cap > 0: hitting cap (this is just for testing purposes)
size_t possible_expansion_words() const;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.