KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Flushing inactive memory on a Mac OS X system
PRODUCT: 4D | VERSION: 11.5 | PLATFORM: Mac OS X
Published On: January 8, 2010
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

When 4D allocates memory it simply requests memory from the operating systems memory manager. When it is done with the memory it is simply released back to the operating system's memory manager. This memory is normally allocated as "Inactive" memory on a Mac OS X system.

Inactive memory is supposed to be reused as Free memory but sometimes the memory manager swaps memory out to disk instead of reusing the Inactive memory. Swapping memory out to disk is known as Paging out the memory; this can cause performance slow downs. For more information see: https://support.apple.com/kb/HT1342

If you install the xCode developer tools and enable the CHUD tools package during installation you'll get a new command, "purge" that can be executed via Launch External Process. The purge MAN page says:

NAME
purge -- force disk cache to be purged (flushed and emptied)

SYNOPSIS
purge

DESCRIPTION
Purge can be used to approximate initial boot conditions with a cold disk
buffer cache for performance analysis. It does not affect anonymous mem-
ory that has been allocated through malloc, vm_allocate, etc.


Using this command via LUNCH EXTERNAL PROCESS can be done easily with the following snippet of code:

C_TEXT($In;$Out)
LAUNCH EXTERNAL PROCESS("purge";$In;$Out)


One location you may want to consider placing this code is in the ON BACKUP SHUTDOWN method to clear the inactive memory after each backup.