E
Emmanuel Schnetzler
Hi all,
this might be a very basic question but I've been struggling with the
problem for a while and can't find the solution.
I am allocating a big chunk of memory that I want to deallocate when I'm
done with it (sorry if I'm mixing C/C++ style language with C#). Here is my
class:
public class Variable: IDisposable
{
private double[] values=null;
public Variable(int n)
{
values=new double[n];
}
public virtual void Dispose()
{
values=null;
System.GC.SuppressFinalize(this);
}
}
The problem is that the memory is not freed when I dispose an instance of
this class:
Variable v=new Variable(8000000);
....
v.Dispose();
v=null;
At this point, when I look at the memory used, it is the same as right after
the object creation. Forcing garbage collection doesn't help. The object is
not referenced anywhere else. Am I missing something?
Any help appreciated!
Manu
this might be a very basic question but I've been struggling with the
problem for a while and can't find the solution.
I am allocating a big chunk of memory that I want to deallocate when I'm
done with it (sorry if I'm mixing C/C++ style language with C#). Here is my
class:
public class Variable: IDisposable
{
private double[] values=null;
public Variable(int n)
{
values=new double[n];
}
public virtual void Dispose()
{
values=null;
System.GC.SuppressFinalize(this);
}
}
The problem is that the memory is not freed when I dispose an instance of
this class:
Variable v=new Variable(8000000);
....
v.Dispose();
v=null;
At this point, when I look at the memory used, it is the same as right after
the object creation. Forcing garbage collection doesn't help. The object is
not referenced anywhere else. Am I missing something?
Any help appreciated!
Manu