MemStat Function

Requires: GfaWinx.lg32

Purpose

Returns information about the memory statistics.

Syntax

Large = MemStat(option)

Description

MemStat returns a Large integer with the information requested by the optional info parameter. The default (info==0, or not specified) returns the memory currently used by the process, either the IDE with your program or the usage of the program’s EXE. The table below specifies the other possible values for the info parameter. These values return information about the current state of both physical and virtual memory obtained with the API function GlobalMemoryStatusEx().

OptionDescription
0Memory currently used by the process.
1 Size of physical memory available, in bytes (ulAvailPhys).
2 Total size of physical memory, in bytes (ullTotalPhys).
3 Size of available memory to commit, in bytes (ullAvailPageFile).
4 Size of the committed memory limit, in bytes (ullTotalPageFile).
5 Size of unreserved and uncommitted memory in the user mode portion of the virtual address space of the calling process, in bytes (ullAvailVirtual).
6 Total size of the user mode portion of the virtual address space of the calling process, in bytes (ullTotalVirtual).
7 Number between 0 and 100 that gives a general idea of current memory utilization, in which 0 indicates no memory use and 100 indicates full memory use (dwMemoryLoad).

Example

Dim mem As Large

Mem = MemStat()          // Memory used by the process

Remarks

The value returned from MemStat(0) can be used to locate memory leakage in a program. Put MemStat(0) at the beginning of the program and Run the program a couple of times. MemStat(0) should report the same amount of memory used (on average). MemStat(0) can also be placed on strategic places in the program to determine the amount of memory the process is currently using.

See Also

mAlloc

{Created by Sjouke Hamstra; Last updated: 07/11/2020 by James Gaite}