问题描述
我正在自动执行一些分析任务,并希望实时记录堆空间和代大小.profiling API 对于我需要的东西来说似乎非常复杂,而且似乎倾听个人的分配和集合,这对我来说并不重要.分析工具当然有很大帮助,但我一直在寻找更灵活、可编程的界面.
I am automating some profiling tasks and want to log heap space and generation sizes real-time. The profiling API seems awfully complicated for what I need, and it seems to listen in on individual allocations and collections, which isn't that important to me. Profiling tools are a great help of course, but I was looking for a more flexible, programmable interface.
推荐答案
术语当前内存使用情况"的定义有点松散.你是说工作集吗?无论它意味着什么,您都可以使用流程类中的不同属性(例如 VirtualMemorySize
、WorkingSet
、PrivateMemorySize
等)来检索它.>
The term 'current memory usage' is a little loosely defined. Do you mean the working set? Whatever it means, you can use different properties such as VirtualMemorySize
, WorkingSet
, PrivateMemorySize
, etc. from the process class to retrieve it.
long workingSet = System.Diagnostics.Process.GetCurrentProcess().WorkingSet64;
这篇关于有没有办法检索 C# 应用程序的当前内存使用情况?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!