private void DoMemoryUpdates() { MemoryMXBean memoryMXBean = ManagementFactory.GetMemoryMXBean(); MemoryUsage memNonHeap = memoryMXBean.GetNonHeapMemoryUsage(); MemoryUsage memHeap = memoryMXBean.GetHeapMemoryUsage(); Runtime runtime = Runtime.GetRuntime(); metrics.SetMetric("memNonHeapUsedM", memNonHeap.GetUsed() / M); metrics.SetMetric("memNonHeapCommittedM", memNonHeap.GetCommitted() / M); metrics.SetMetric("memHeapUsedM", memHeap.GetUsed() / M); metrics.SetMetric("memHeapCommittedM", memHeap.GetCommitted() / M); metrics.SetMetric("maxMemoryM", runtime.MaxMemory() / M); }
private void GetMemoryUsage(MetricsRecordBuilder rb) { MemoryUsage memNonHeap = memoryMXBean.GetNonHeapMemoryUsage(); MemoryUsage memHeap = memoryMXBean.GetHeapMemoryUsage(); Runtime runtime = Runtime.GetRuntime(); rb.AddGauge(JvmMetricsInfo.MemNonHeapUsedM, memNonHeap.GetUsed() / M).AddGauge(JvmMetricsInfo .MemNonHeapCommittedM, memNonHeap.GetCommitted() / M).AddGauge(JvmMetricsInfo.MemNonHeapMaxM , memNonHeap.GetMax() / M).AddGauge(JvmMetricsInfo.MemHeapUsedM, memHeap.GetUsed () / M).AddGauge(JvmMetricsInfo.MemHeapCommittedM, memHeap.GetCommitted() / M).AddGauge (JvmMetricsInfo.MemHeapMaxM, memHeap.GetMax() / M).AddGauge(JvmMetricsInfo.MemMaxM , runtime.MaxMemory() / M); }