简体   繁体   English

如何确定vb.net中未使用的总物理内存

[英]How to determine total unused physical memory in vb.net

I want to limit the number of threads I create based on the amount of free physical memory. 我想根据可用物理内存的数量来限制创建的线程数。 For instance I want to stop making new threads once I reach the point that there is only 7GB of real memory left. 例如,一旦达到剩余的7GB实际内存,我想停止创建新线程。 How would I do so? 我该怎么办?

You can use Devices.ComputerInfo to get the total amount of free physical memory: 您可以使用Devices.ComputerInfo来获取可用物理内存的总量:

Dim info = New Microsoft.VisualBasic.Devices.ComputerInfo()
Dim gb = info.AvailablePhysicalMemory / 1024 / 1024 / 1024
While gb >= 7
    ' start your threads here ... '
    gb = info.AvailablePhysicalMemory / 1024 / 1024 / 1024
End While

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM