P
Palm Kevin
I observed a strange behaviour in my program.
When I create too much objects, the garbage collector seems to not be
able free the allocated memory.
Example where the GC frees memory:
ArrayList c = new ArrayList();
for(int i = 0; i < 200; i ++)
{
c.Add(new char[500000]);
}
c = null;
GC.Collect();
The free memory before loop : 27.26
The free memory after loop : 10.49
The free memory after GC : 27
In the previous example the GC freed 16.51 Mb
Now consider the following example.
ArrayList al = new ArrayList();
for(int i = 0; i < 500; i ++)
{
al.Add(new char[200000]);
}
al = null;
GC.Collect();
The free memory before loop : 27.26
The free memory after loop : 2.69
The free memory after GC : 2.69
Here the GC freed NOTHING!?
Has somebody an explication for this???
When I create too much objects, the garbage collector seems to not be
able free the allocated memory.
Example where the GC frees memory:
ArrayList c = new ArrayList();
for(int i = 0; i < 200; i ++)
{
c.Add(new char[500000]);
}
c = null;
GC.Collect();
The free memory before loop : 27.26
The free memory after loop : 10.49
The free memory after GC : 27
In the previous example the GC freed 16.51 Mb
Now consider the following example.
ArrayList al = new ArrayList();
for(int i = 0; i < 500; i ++)
{
al.Add(new char[200000]);
}
al = null;
GC.Collect();
The free memory before loop : 27.26
The free memory after loop : 2.69
The free memory after GC : 2.69
Here the GC freed NOTHING!?
Has somebody an explication for this???