KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: How do you procedurally detect available memory?
PRODUCT: 4D Pack | VERSION: 6.7 | PLATFORM: Mac & Win
Published On: February 14, 2002

There are times when you may want to detect the available memory for a 4D application. For example, when starting a new process you may want to know if there is sufficient memory to launch the new process.



To test the available memory, you can use the 4D Pack command AP AVAILABLE MEMORY. Its definition is as follows:



AP AVAILABLE MEMORY (totalMemory; physicalMemory; freeMemory; freeStack)

The AP AVAILABLE MEMORY command returns information in bytes on the installed and free memory on the machine where it is executed. The command returns the machine installed memory (total and physical), the free memory available for 4D, and the free stack (rounded to the closest Kb) for the current process.



The following code would be a good example of how to use that command:



AP AVAILABLE MEMORY (totalMemory; physicalMemory; freeMemory; freeStack)

if(freestack>RequiredMemory)



 $vlProcessID:=New process("Add Customers";32*1024;"Adding Customers";*)

 If ($vlProcessID#0)

   BRING TO FRONT ($vlProcessID)

 End if

Else

 Alert("Not enough memory to start New process")

End if



Note: The plug-in can be downloaded from the following location: http://4d.com/downloads/products.html