Ejemplo n.º 1
0
        public static PerfomanceInfoData GetPerformanceInfo()
        {
            PerfomanceInfoData data = new PerfomanceInfoData();
            PsApiPerformanceInformation perfInfo = new PsApiPerformanceInformation();
            if (GetPerformanceInfo(out perfInfo, Marshal.SizeOf(perfInfo)))
            {
                /// data in pages
                data.CommitTotalPages = perfInfo.CommitTotal.ToInt64();
                data.CommitLimitPages = perfInfo.CommitLimit.ToInt64();
                data.CommitPeakPages = perfInfo.CommitPeak.ToInt64();

                /// data in bytes
                Int64 pageSize = perfInfo.PageSize.ToInt64();
                data.PhysicalTotalBytes = perfInfo.PhysicalTotal.ToInt64() * pageSize;
                data.PhysicalAvailableBytes = perfInfo.PhysicalAvailable.ToInt64() * pageSize;
                data.SystemCacheBytes = perfInfo.SystemCache.ToInt64() * pageSize;
                data.KernelTotalBytes = perfInfo.KernelTotal.ToInt64() * pageSize;
                data.KernelPagedBytes = perfInfo.KernelPaged.ToInt64() * pageSize;
                data.KernelNonPagedBytes = perfInfo.KernelNonPaged.ToInt64() * pageSize;
                data.PageSizeBytes = pageSize;

                /// counters
                data.HandlesCount = perfInfo.HandlesCount;
                data.ProcessCount = perfInfo.ProcessCount;
                data.ThreadCount = perfInfo.ThreadCount;
            }

            return data;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get physical memory information
        /// </summary>
        private void GetPhysicalMemoryInformation()
        {
            this.performanceInfoData = PsApiWrapper.GetPerformanceInfo();

            var AvailableGb = this.performanceInfoData.PhysicalAvailableBytes.ToPrettySize(1);
            var UsedGb = (this.performanceInfoData.PhysicalTotalBytes - this.performanceInfoData.PhysicalAvailableBytes).ToPrettySize(1);

            this.UsedPhysicalMemoryInPercent = (double)(this.performanceInfoData.PhysicalTotalBytes - this.performanceInfoData.PhysicalAvailableBytes) / this.performanceInfoData.PhysicalTotalBytes * 100;
            this.UsedPhysicalMemory = (this.performanceInfoData.PhysicalTotalBytes - this.performanceInfoData.PhysicalAvailableBytes).ToPrettySize(1);
            this.FreePhysicalMemoryInPercent = (double)100 - this.UsedPhysicalMemoryInPercent;
            this.FreePhysicalMemory = this.performanceInfoData.PhysicalAvailableBytes.ToPrettySize(1);

            if (this.CurrentRAMWorkloadSeries != null && this.CurrentRAMWorkloadSeries.Count == 0)
            {
                this.CurrentRAMWorkloadSeries.Add(new ChartDataPoint() { Name = "Used Physical Memory", Value = this.UsedPhysicalMemoryInPercent });
            }
            else
            {
                this.CurrentRAMWorkloadSeries.FirstOrDefault().Value = this.UsedPhysicalMemoryInPercent;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get physical memory information
        /// </summary>
        private void GetMemoryInformaton()
        {
            this.performanceInfoData = PsApiWrapper.GetPerformanceInfo();

            var AvailableGb = this.performanceInfoData.PhysicalAvailableBytes.ToPrettySize(1);
            var UsedGb = (this.performanceInfoData.PhysicalTotalBytes - this.performanceInfoData.PhysicalAvailableBytes).ToPrettySize(1);

            this.UsedPhysicalMemoryInPercent = (double)(this.performanceInfoData.PhysicalTotalBytes - this.performanceInfoData.PhysicalAvailableBytes) / this.performanceInfoData.PhysicalTotalBytes * 100;
            this.FreePhysicalMemoryInPercent = (double)100 - this.UsedPhysicalMemoryInPercent;

            this.OnPropertyChanged(() => this.UsedPhysicalMemory);
            this.OnPropertyChanged(() => this.FreePhysicalMemory);
        }