KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Database Cache settings in 4D 2004 (memory allocation)
PRODUCT: 4D Server | VERSION: 2004.1 | PLATFORM: Mac & Win
Published On: March 17, 2005
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

In 4D Server Preferences, topic Database, subtopic Data Management, there is a section where you can set application memory and database cache size. There are two main configurations, Forced and Adaptive cache settings.

1) The Forced cache setting is set when the checkbox "Calculation of adaptive cache" is not checked. Only one option is available to set, which manually sets the 4D Server database cache size. The database cache is set to this size regardless of the machine resources available.

2) The Adaptive setting (the above checkbox is checked) has a more versatile behavior. Memory allocation is calculated dynamically and respects the limits you set.
a) Physical Memory to be reserved - This is the amount of memory you wish to leave available to the system and all other applications on the machine. 4D will be limited from accessing this amount of physical memory.
b) Percentage of available memory used for the cache - Take all physical RAM on your system, subtract the amount of memory in the "reserved" setting, and then multiply by the percentage you place in this settting, and that is the the calculation of how much memory is set for your database cache.
c) "Maximum Size" is an absolute limit on the maximum database cache size. If the above calculation exceeds the Maximum Size, the cache size will be set to this limit.
d) "Minimum Size" is the smallest the cache can get when there are at least enough memory resources to reach the minimum. The cache can be smaller than this size if there is not enough available memory.

How the cache is calculated:
The database cache calculation begins by subtracting the "Physical memory to be reserved" from the physical memory installed on the system. The "Percentage of available memory" is applied to that difference. If the resulting amount of memory does not exceed the maximum or minimum "Size" limits, then the database cache will be set to the calculated size. If the result exceeds a "Size" limit, it will be set equal to the value of that size limit. The "current cache", also found in the "Database Cache Settings" section, reports the calculated amount for the running instance of 4D, and the "Cache on Restart" is the value that 4D will use in its next running instance (when you shutdown and restart 4D).

- For example, you have 1 GB (1024 MB) of physical RAM on your machine. You set 256 MB to be reserved for the system. So 4D has access to 768MB of physical RAM. Then you set the percentage of available memory used for the cache to 80%. 4D uses the percentage to calculate (1024 - 256)*0.80 for an estimated cache size of 614 MB. Lets say your the maximum cache size to 512MB and the minimum cache size to 100MB. The actual database cache size will be 512MB RAM because the original calculation exceeded the maximum limit that you set.

Commented by Jody Bevan on April 13, 2011 at 10:04 AM
I believe that this note needs to make it clear that this is the amount of RAM this is available not the RAM installed. This is because the OS and all the tag along application that are running before 4D is started have already grabbed the RAM they need. Therefore these settings are what 4D asks from the OS of what is left.

Thus in the case above, if when 4D is started there is 512MB of RAM free, the 4D application can only get a maximum of 512MB no matter what the settings are. The OS does not give to 4D the full 1GIG as other applications are using it.

I would like the note updated to reflect this operating reality. Of course I could be wrong and thus am always open to being educated.
Commented by Jody Bevan on April 13, 2011 at 10:04 AM
I believe that this note needs to make it clear that this is the amount of RAM this is available not the RAM installed. This is because the OS and all the tag along application that are running before 4D is started have already grabbed the RAM they need. Therefore these settings are what 4D asks from the OS of what is left.

Thus in the case above, if when 4D is started there is 512MB of RAM free, the 4D application can only get a maximum of 512MB no matter what the settings are. The OS does not give to 4D the full 1GIG as other applications are using it.

I would like the note updated to reflect this operating reality. Of course I could be wrong and thus am always open to being educated.