When working with the Fore language in Foresight Analytics Platform, garbage collection is implemented that helps delete unused objects and free computer memory. The garbage collector starts automatically at system idle time.
If other development environments are used to work with Fore language resources, the application developer must manage the allocation and release of memory. The following methods of the Prognoz.Platform.Interop.Fore.IForeRuntime interface start the collection process:
CollectFullGarbage. Starts cyclic garbage collection that deletes all unused objects and the related objects that are no longer being used. The method is executed until its algorithm finds and deletes unused objects. (Method execution may take a considerable amount of time).
CollectGarbage. Performs a garbage collection cycle. Returns True if some objects have been deleted. The Check output parameter is set to True if no errors occurred at the method runtime.
The methods starting garbage collection, which is executed in asynchronous mode in another thread, can be used:
RequestFullClean. Starts garbage collection providing a possibility to limit its execution time. If the specified time is not enough for checking and cleaning, the process will be aborted and it will be resumed when required conditions will be restored.
RequestPartitialClean. Performs a garbage collection cycle.
These methods should be called within connection to the repository, with which the user is working.
The example of garbage collector start on C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Prognoz.Platform.Interop.Fore;
using Prognoz.Platform.Interop.Metabase;
namespace TestProject
{
public partial class Form1 : Prognoz.Platform.Forms.Net.ForeNetFormVS
{
public Form1()
{
InitializeComponent();
}
//...
private void button1_Click(object sender, EventArgs e)
{
IForeServices Svc = (IForeServices)this.Metabase;
IForeRuntime ForeRun = Svc.GetRuntime();
ForeRun.CollectFullGarbage();
}
//...
}
}
See also:
Using Foresight Analytics Platform Resources in Third-Party Applications