public PhysMemHistoryIcon()
        {
            this.UseSecondLine = false;
            this.UseLongData = true;

            PerformanceInformation info = new PerformanceInformation();

            info.Size = Marshal.SizeOf(info);
            Win32.GetPerformanceInfo(out info, info.Size);
            this.MinMaxValue = info.PhysicalTotal.ToInt64();
        }
        public CommitHistoryIcon()
        {
            this.UseSecondLine = false;
            this.UseLongData = true;

            PerformanceInformation info = new PerformanceInformation
            {
                cbSize = PerformanceInformation.SizeOf
            };

            Win32.GetPerformanceInfo(out info, info.cbSize);

            this.MinMaxValue = info.CommitLimit.ToInt64();
        }
Esempio n. 3
0
        private void UpdateInfo()
        {
            var perfInfo = Program.ProcessProvider.Performance;
            var info = new PerformanceInformation();

            Win32.GetPerformanceInfo(out info, System.Runtime.InteropServices.Marshal.SizeOf(info));

            SystemCacheInformation cacheInfo;
            int retLen;

            Win32.NtQuerySystemInformation(SystemInformationClass.SystemFileCacheInformation,
                out cacheInfo, Marshal.SizeOf(typeof(SystemCacheInformation)), out retLen);

            // Totals
            labelTotalsProcesses.Text = ((ulong)info.ProcessCount).ToString("N0");
            labelTotalsThreads.Text = ((ulong)info.ThreadCount).ToString("N0");
            labelTotalsHandles.Text = ((ulong)info.HandlesCount).ToString("N0");
            labelTotalsUptime.Text = Utils.FormatLongTimeSpan(Windows.GetUptime());

            // Commit
            labelCCC.Text = Utils.FormatSize((ulong)perfInfo.CommittedPages * _pageSize);
            labelCCP.Text = Utils.FormatSize((ulong)perfInfo.PeakCommitment * _pageSize);
            labelCCL.Text = Utils.FormatSize((ulong)perfInfo.CommitLimit * _pageSize);

            // Physical Memory
            string physMemText = Utils.FormatSize((ulong)(_pages - perfInfo.AvailablePages) * _pageSize);

            labelPMC.Text = physMemText;
            labelPSC.Text = Utils.FormatSize((ulong)info.SystemCache * _pageSize);
            labelPMT.Text = Utils.FormatSize((ulong)_pages * _pageSize);

            // Update the physical memory indicator here because we have perfInfo available.

            indicatorPhysical.Data1 = _pages - perfInfo.AvailablePages;
            indicatorPhysical.TextValue = physMemText;

            // File cache
            labelCacheCurrent.Text = Utils.FormatSize(cacheInfo.SystemCacheWsSize);
            labelCachePeak.Text = Utils.FormatSize(cacheInfo.SystemCacheWsPeakSize);
            labelCacheMinimum.Text = Utils.FormatSize((ulong)cacheInfo.SystemCacheWsMinimum * _pageSize);
            labelCacheMaximum.Text = Utils.FormatSize((ulong)cacheInfo.SystemCacheWsMaximum * _pageSize);

            // Paged/Non-paged pools
            labelKPPPU.Text = Utils.FormatSize((ulong)perfInfo.ResidentPagedPoolPage * _pageSize);
            labelKPPVU.Text = Utils.FormatSize((ulong)perfInfo.PagedPoolPages * _pageSize);
            labelKPPA.Text = ((ulong)perfInfo.PagedPoolAllocs).ToString("N0");
            labelKPPF.Text = ((ulong)perfInfo.PagedPoolFrees).ToString("N0");
            labelKPNPU.Text = Utils.FormatSize((ulong)perfInfo.NonPagedPoolPages * _pageSize);
            labelKPNPA.Text = ((ulong)perfInfo.NonPagedPoolAllocs).ToString("N0");
            labelKPNPF.Text = ((ulong)perfInfo.NonPagedPoolFrees).ToString("N0");

            // Get the pool limits
            long pagedLimit = 0;
            long nonPagedLimit = 0;

            if (
                _mmSizeOfPagedPoolInBytes != IntPtr.Zero &&
                _mmMaximumNonPagedPoolInBytes != IntPtr.Zero &&
                KProcessHacker.Instance != null
                )
            {
                try
                {
                    int pl, npl;

                    this.GetPoolLimits(out pl, out npl);
                    pagedLimit = pl;
                    nonPagedLimit = npl;
                }
                catch
                { }
            }

            if (pagedLimit != 0)
                labelKPPL.Text = Utils.FormatSize(pagedLimit);
            else if (KProcessHacker.Instance == null)
                labelKPPL.Text = "no driver";
            else
                labelKPPL.Text = "no symbols";

            if (nonPagedLimit != 0)
                labelKPNPL.Text = Utils.FormatSize(nonPagedLimit);
            else if (KProcessHacker.Instance == null)
                labelKPNPL.Text = "no driver";
            else
                labelKPNPL.Text = "no symbols";

            // Page faults
            labelPFTotal.Text = ((ulong)perfInfo.PageFaultCount).ToString("N0");
            labelPFCOW.Text = ((ulong)perfInfo.CopyOnWriteCount).ToString("N0");
            labelPFTrans.Text = ((ulong)perfInfo.TransitionCount).ToString("N0");
            labelPFCacheTrans.Text = ((ulong)perfInfo.CacheTransitionCount).ToString("N0");
            labelPFDZ.Text = ((ulong)perfInfo.CacheTransitionCount).ToString("N0");
            labelPFCache.Text = ((ulong)cacheInfo.SystemCacheWsFaults).ToString("N0");

            // I/O
            labelIOR.Text = ((ulong)perfInfo.IoReadOperationCount).ToString("N0");
            labelIORB.Text = Utils.FormatSize(perfInfo.IoReadTransferCount);
            labelIOW.Text = ((ulong)perfInfo.IoWriteOperationCount).ToString("N0");
            labelIOWB.Text = Utils.FormatSize(perfInfo.IoWriteTransferCount);
            labelIOO.Text = ((ulong)perfInfo.IoOtherOperationCount).ToString("N0");
            labelIOOB.Text = Utils.FormatSize(perfInfo.IoOtherTransferCount);

            // CPU
            labelCPUContextSwitches.Text = ((ulong)perfInfo.ContextSwitches).ToString("N0");
            labelCPUInterrupts.Text = ((ulong)Program.ProcessProvider.ProcessorPerf.InterruptCount).ToString("N0");
            labelCPUSystemCalls.Text = ((ulong)perfInfo.SystemCalls).ToString("N0");
        }