3

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 :-)

4
  • 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? Commented Oct 12, 2015 at 13:47
  • Sorry, i mean System free, available and cache memory (on windows) via vb .net code Thanks a lot Commented Oct 12, 2015 at 14:02
  • did you asking about free Ram space? Commented Oct 12, 2015 at 14:03
  • yup, free ram, not available... Commented Oct 12, 2015 at 14:07

2 Answers 2

3

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,

running app view

Sign up to request clarification or add additional context in comments.

Comments

0

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

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...
@Alessandro can you please explain what is the difference between free and available space?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.