Log In    |    Knowledge Base    |    4D Home
Tech Tip: Memory and cache settings
Published On: February 12, 2004

It is useless to assign all your memory to the cache setting if you do not need it. It may even be problematic if you are not giving enough memory to the main memory.

The cache holds the loaded records or index pages. 4D also keeps transactions in the cache, but if a transaction becomes too big, it will be swapped into a temporary file. Everything else is held in the main memory. When displaying a form, loading a method, or creating variables, you are going to use the memory from the main memory. It is important to know an approximate size of memory that each of your processes will require. 4D may have to duplicate or even quadruple this size. You might add some extra blocks in case you have to face an overload or to handle some unusually huge data. Keep in mind that your memory may be fragmented after an intensive use of memory.

You can also try to compute the size of your index tables, and the size of your records for the most used items, and estimate what could be the average memory required for the cache. The Runtime Explorer is a very good tool to use to see what you loaded in the cache, the use, the number of hits and percentage in the cache. A low percentage often indicates that the cache size is too small.

Once you know the requirements for the main memory and the cache, you will have a better idea on how to assign these values. You can then define the settings of memory in relation to what is available on the machine. Keep in mind that you cannot assign more than 2 Gb to any application, 4D included (i.e. the sum of both memory settings cannot be greater than 2 Gb). Unfortunately, since the use of virtual memory is not recommended for performance reasons, you might have to choose a difficult compromise if you do not have enough memory on your machine.