java/lang/management/MemoryMXBean/CollectionUsageThreshold.java fails consistently with G1.
The test lowers the notification threshold for the G1 old gen memory pool and expects to get a notification after a full GC.
The problem in G1 is that the decision to send the notification is done in TraceMemoryManagerStats::~TraceMemoryManagerStats(). This eventually does pool->get_memory_usage() to get the memory usage after a collection. The problem is that we update this information in G1MonitoringSupport::update_sizes() which is called in G1CollectedHeap::do_collection() _after_ the TraceMemoryManagerStats scope had been exited.
Extending the scope to cover the call to G1MonitoringSupport::update_sizes() solves the issue.