S
Sudip_inn
Guest
1) in one of my routine i used many list and dataset. i populated those with high volume of data. when event used end then clear memory for list like
list1 = null and GC.Collect() in my routine but i am not sure that memory occupied by List1 is instantly clear or will be clear later. please share the knowledge.
2) in case of dataset i clear like
dataset1.Dispose()
dataset1=null
GC.Collect()
but i am not sure that memory occupied by dataset1 is instantly clear or will be clear later. please share the knowledge.
3) if i call GC.Collect() several time in my one routine does degrade the performance of my application ?
i found one link which said best option to release memory for list this way
first clear List and then call TrimExcess. is it the right one ?
i used like list1=null & GC.Collect()
which one is best to clear memory for list instantly ?
please see my code below which works well.
private void button2_Click(object sender, EventArgs e)
{
var before = System.Diagnostics.Process.GetCurrentProcess().VirtualMemorySize64;
List<string> lst1 = new List<string>();
for (int i = 0; i <= 1000000; i++)
{
lst1.Add("Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test ");
}
var after = System.Diagnostics.Process.GetCurrentProcess().VirtualMemorySize64;
lst1.Clear();
lst1.TrimExcess();
var current = System.Diagnostics.Process.GetCurrentProcess().VirtualMemorySize64;
}
please share best option to clear memory for list & dataset instantly. thanks
Continue reading...
list1 = null and GC.Collect() in my routine but i am not sure that memory occupied by List1 is instantly clear or will be clear later. please share the knowledge.
2) in case of dataset i clear like
dataset1.Dispose()
dataset1=null
GC.Collect()
but i am not sure that memory occupied by dataset1 is instantly clear or will be clear later. please share the knowledge.
3) if i call GC.Collect() several time in my one routine does degrade the performance of my application ?
i found one link which said best option to release memory for list this way
first clear List and then call TrimExcess. is it the right one ?
i used like list1=null & GC.Collect()
which one is best to clear memory for list instantly ?
please see my code below which works well.
private void button2_Click(object sender, EventArgs e)
{
var before = System.Diagnostics.Process.GetCurrentProcess().VirtualMemorySize64;
List<string> lst1 = new List<string>();
for (int i = 0; i <= 1000000; i++)
{
lst1.Add("Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test ");
}
var after = System.Diagnostics.Process.GetCurrentProcess().VirtualMemorySize64;
lst1.Clear();
lst1.TrimExcess();
var current = System.Diagnostics.Process.GetCurrentProcess().VirtualMemorySize64;
}
please share best option to clear memory for list & dataset instantly. thanks
Continue reading...