KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: How much swap space is 4D using?
PRODUCT: 4D | VERSION: 15.x | PLATFORM: Mac & Win
Published On: February 26, 2016

The GET MEMORY STATISTICS command returns important information such as how much physical memory (RAM) is being used in addition to how much overall virtual memory the application has been allocated. Using these two values we can determine the amount of memory that has been swapped back to disk by using the following calculation:

Used Virtual Memory - Used Physical Memory = Memory Swapped to disk


The following utility method can be used to determine how much of the current applications memory has been swapped to disk:
// UTIL_HowMuchMemIsSwap
// returns the amount of memory swapped to disk in bytes
// $0 = C_REAL
C_REAL($0)
ARRAY TEXT(arrNames;0)
ARRAY REAL(arrValues;0)
ARRAY REAL(arrCount;0)
GET MEMORY STATISTICS(1;arrNames;arrValues;arrCount)
If (Size of array(arrValues)>=8)
   $0:=arrValues{6}-arrValues{5}
End if


If the utility method is saved as UTIL_HowMuchMemIsSwap it could be used like this:
ALERT(String(UTIL_HowMuchMemIsSwap ;"###,###,###,##0"))

See Also: