Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: VB5,VB6
Expertise: beginner
Oct 13, 2001



Application Security Testing: An Integral Part of DevOps

Determine memory usage

The GlobalMemoryStatus API function returns detailed information about the current load on the physical and virtual memory. You can use the following code to display the current amount of free memory:

    Dim msg As String
    ' query for memory data
    ms.dwLength = Len(ms)
    GlobalMemoryStatus ms
    ' create a result message.
    msg = "Total physical memory = " & GetKbytes(ms.dwTotalPhys) & vbCrLf & _
        "Available physical memory = " & GetKbytes(ms.dwAvailPhys) & vbCrLf & _
        "Memory Load = " & ms.dwMemoryLoad & "%" & vbCrLf & _
        "Total Page file = " & GetKbytes(ms.dwTotalPageFile) & vbCrLf & _
        "Available Page file = " & GetKbytes(ms.dwAvailPageFile) & vbCrLf & _
        "Total Virtual memory = " & GetKbytes(ms.dwTotalVirtual) & vbCrLf & _
        "Available Virtual memory = " & GetKbytes(ms.dwAvailVirtual)
    MsgBox msg, vbInformation, "Memory information"
The GetKbytes function is a simple routine that converts a number of bytes into Kbytes, and adds thousand separators:

' Format a memory amoung as a Kbyte or Megabyte

Function GetKbytes(ByVal amount As Long) As String
    ' convert to Kbytes
    amount = amount \ 1024
    GetKbytes = Format(amount, "###,###,###K")
End Function
Francesco Balena
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date