When developing projects in the Fore language, garbage collection is necessary in some specific situations when the system cannot automatically delete an object based on some systematic criteria. For example, when there are two unused objects A and B in the system that refer to each other, the system cannot delete them because their links counter is non-zero. To resolve such situations, the system periodically collects garbage and marks all active objects, the rest of them are deleted.
Garbage collection is executed in a single stream (a single stream is generated for each repository connection). The following method is used by default: garbage collection is executed if no application methods are running; the system checks if it is possible to collect garbage each two seconds. If required, the method can be changed using registry keys.
The following keys can be created in the registry key [HKEY_CURRENT_USER\Software\Foresight\Foresight Analytics Platform\10.0\Fore]:
Parameter | Description |
GCStrategy (REG_DWORD) | Garbage collection method. A binary one-byte number in the decimal format is set as a value. The first three bits of the number are not used. The rest five bits can be used to enable the following modes:
Various modes can be used at the same time. The default mode corresponds with the 00001001 number in the binary system or to the 9 number in the decimal system. |
GCInterval (REG_DWORD) | Garbage collection check interval. The value is set in milliseconds. |
The change of the garbage collection method may slow down running code work and developed application work in general. Disabling of garbage collection and force call of methods of the IForeGarbageCollector interface may be necessary when the developer knows exactly when resource-intensive tasks are running, after which unused object may be left in the memory. Regular garbage collection (the 00000010 mode) may be required on computers with small-size RAM, which may be overloaded very quickly.
See also: