Reputation: 33130
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. How would I do so?
Upvotes: 2
Views: 1677
Reputation: 460208
You can use Devices.ComputerInfo
to get the total amount of free physical memory:
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
Upvotes: 4