そのため、作成したクラスのデストラクタの実装を検討していましたが、実際にメモリを解放する方法や、これがガベージ コレクションによって処理されるかどうかはわかりません。
class AutomatedTest
{
public bool testComplete = false;
public bool testStopRequest = false;
public List<Command> commandList = new List<Command>();
private bool loggingEnabled = false;
...
public AutomatedTest(TestList testToCreate)
{
// Create a list of Command objects and add them to the list
}
}
クラスの使用方法:
for(int numTests = 0; numTests < 20; numTests++)
{
AutomatedTest test1 = new AutomatedTest(TestList._1DayTest);
RunAutoTest(test1);
AutomatedTest test2 = new AutomatedTest(TestList._2DayTest);
RunAutoTest(test2);
AutomatedTest test3 = new AutomatedTest(TestList._3DayTest);
RunAutoTest(test3);
AutomatedTest test4 = new AutomatedTest(TestList._4DayTest);
RunAutoTest(test4);
}
したがって、4 つのオブジェクトが作成されて実行され、これが 20 回行われます。
私の質問は、これらのオブジェクトを適切に破棄/破棄するにはどうすればよいですか? これらがガベージコレクションされているとは思いたくありませんが、デストラクタの実装は初めてです。