i'm having some problem with a multithread software wrote on vb .net, i need to get not only the available free memory (got with PerformanceCounter) but also cache and, better, the free memory on the system. How may i do that? Thanks a lot :-)
-
Can you review your question please? I don't know what you asking. Do you mean you want your system specifications? or you want the amount of memory being used by your software? Can you show some code too?ScarletMerlin– ScarletMerlin2015-10-12 13:47:45 +00:00Commented Oct 12, 2015 at 13:47
-
Sorry, i mean System free, available and cache memory (on windows) via vb .net code Thanks a lotAlessandro– Alessandro2015-10-12 14:02:53 +00:00Commented Oct 12, 2015 at 14:02
-
did you asking about free Ram space?Sankar– Sankar2015-10-12 14:03:36 +00:00Commented Oct 12, 2015 at 14:03
-
yup, free ram, not available...Alessandro– Alessandro2015-10-12 14:07:45 +00:00Commented Oct 12, 2015 at 14:07
Add a comment
|
2 Answers
You can get Free memory from Performance Counter "\Memory\Free & Zero Page List Bytes".
Besides, I uploaded a sample project on https://github.com/stjeong/DotNetSamples/tree/master/WinConsole/MemoryPartOfTaskManagerAndResourceMonitor
With this in place, you can get all of the memory info as follows,
Comments
Try this...
Public Sub getAvailableRAM()
Dim CI As New ComputerInfo()
Dim avl, used As String
Dim mem As ULong = ULong.Parse(CI.AvailablePhysicalMemory.ToString())
Dim mem1 As ULong = ULong.Parse(CI.TotalPhysicalMemory.ToString()) - ULong.Parse(CI.AvailablePhysicalMemory.ToString())
avl = (mem / (1024 * 1024) & " MB").ToString() 'changed + to &
used = (mem1 / (1024 * 1024) & " MB").ToString() 'changed + to &
End Sub
for using ComputerInfo class you have to import Imports Microsoft.VisualBasic.Devices
I hope you understood my snippet and FYI:- The available ram space is dynamically changing one.
If you face any difficulties on this, Feel free to ask...
2 Comments
Alessandro
Thanks a lot, but i need the free memory not the available, i always have problem when free almost reach 0, in that case available memory have still many space to use...
Sankar
@Alessandro can you please explain what is the difference between free and available space?
