I have the following class:
public class test
{
public int datacapturecount { get; set; }
public int sno { get; set; }
public string name { get; set; }
public string sourceaddr { get; set; }
public string destaddr { get; set; }
public string Bssid { get; set; }
public string packetsubtype { get; set; }
public UInt16 datarate { get; set; }
public SByte signal { get; set; }
public UInt32 channel { get; set; }
public UInt32 size { get; set; }
}
I am using this class while adding rows to wpf datagrid In a infinite loop:
for(I=0; ; I++)
{
datagrid.Items.Add(new test() {
datacapturecount = 0,
sno = I,
name = "ssss",
sourceaddr = "44545454"
});
}
Here the class test is creating multiple instances and causing memory leaks. How to avoid this? How to Write destructor for above class so that I can force the GC to collect the memory immediately after adding the row to datagrid?