Is there any way to get available virtual and physical memory size when running under Mono?
相关问题
- Generic Generics in Managed C++
- How to Debug/Register a Permanent WMI Event Which
- 'System.Threading.ThreadAbortException' in
- Bulk update SQL Server C#
- Should I use static function in c# where many call
You could use this implementation of the "free" command (UNIX) to find out used and available physical memory (it is the best option IMHO):
Alternatively, it could be used sysconf (UNIX) to get the currently available pages of physical memory. This value depends on how many data the OS has cached, because of that, you should execute
echo 3 > /proc/sys/vm/drop_caches
before running this code:I haven't use much Mono, but have you tried looking through the Mono Profiler logs? I know they show physical memory, but i'm not sure about virtual...
Call me curious, but why do you need these? If you are having problems with memory usage in your app, there are plenty of different techniques you can use to help reduce it...
Edit: Doing a look around, there really isn't a mono specific way to gather it... However, depending on how you are running your application, you can still access the current process object in C#
Then just use/return those as you see fit.
source: MSDN