Garbage Collection

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:

  • 00010000 bit. Garbage collection is started on exceeding the limit of occupied virtual memory (size of checked limit is fixed and is equal to 50% of virtual memory).

  • 00001000 bit. Availability of garbage collection is checked with the time interval specified in the GCInterval key.

  • 00000100 key. Garbage collection is not executed. Methods of the IForeGarbageCollector interface can be used to start garbage collection.

  • 00000010 bit. An attempt to execute garbage collection is made after each action of the Fore language interpreter.

  • 00000001 bit. Garbage collection is executed if no application methods are running. This mode is used by default.

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:

Additional Settings of Development Environment