Re initialize the size of array but face OutOfmemoryException

M

macneed

i wrote a program that have a large size array, but the size is change often
(about 3 -4 mins)

the program like that:

public class MemoryArray
{
public float[,,] MM;

public MemoryArray(int Size)
{
MM = new float[Size, 10000, 10000];
}
}

static void Main(string[] args)
{
int[] SizeArray = { 100, 200, 300, 400 };
MemoryArray MA = new MemoryArray(1);
int i=0;

while (true)
{
MA = null; // I try to use it to release memory
GC.Collect();

MA = new MemoryArray(SizeArray[i++%4];
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top