By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,190 Members | 765 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,190 IT Pros & Developers. It's quick & easy.

Arrays and OutOfMemoryException

P: n/a
Hi, I'm programming on Visual C# Express Beta 2 and I have the following
code:

class MyClass
{
int[] a = new int[30]
int [,] b = new int[10,20]

public int SomeMethod()
}

class OtherClass
{
MyClass[] cls = null;

public void DoSomething()
{
int a = 3000;
cls = new MyClass[a];
}
}

class program
{
OtherClass other = new OtherClass();

public int main()
{
other.DoSomething()
}
}

When running on Debug , this code works as expected, but on Release I get an
OutOfMemoryException allocatting the array on "cls = new MyClass[a]" when
calling "DoSomething"

Can someone help me to solve it?

Thanks in advance

Fernando


Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a


"Fernando Casero" wrote:
Hi, I'm programming on Visual C# Express Beta 2 and I have the following
code:

class MyClass
{
int[] a = new int[30]
int [,] b = new int[10,20]

public int SomeMethod()
}

class OtherClass
{
MyClass[] cls = null;

public void DoSomething()
{
int a = 3000;
cls = new MyClass[a];
}
}

class program
{
OtherClass other = new OtherClass();

public int main()
{
other.DoSomething()
}
}

When running on Debug , this code works as expected, but on Release I get an
OutOfMemoryException allocatting the array on "cls = new MyClass[a]" when
calling "DoSomething"

Can someone help me to solve it?

Thanks in advance

Fernando


please explane more ,, it s not clear
Nov 17 '05 #2

P: n/a
Fernando,

First, If this is C# code you are trying to compile then it will not
compile. It is buggy with small syntex errors.
Second, after fixing those syntex errors this program it should not give you
any error, release or debug do not matter.

OutOfMemoryException is thrown when you don't have enought memory to run
application. Please post the code that you are using.

I am pasting running code below.

class MyClass
{
int[] a = new int[30];
int [,] b = new int[10,20];
public int SomeMethod()
{
return 0;
}
}

class OtherClass
{
MyClass[] cls = null;
public void DoSomething()
{
int a = 3000;
cls = new MyClass[a];
}
}

public class Class1
{
public static void Main()
{
OtherClass other = new OtherClass();
other.DoSomething();
Console.Read();
}
}

"Fernando Casero" <fe************@speedy.com.ar> wrote in message
news:O7**************@TK2MSFTNGP12.phx.gbl...
Hi, I'm programming on Visual C# Express Beta 2 and I have the following
code:

class MyClass
{
int[] a = new int[30]
int [,] b = new int[10,20]

public int SomeMethod()
}

class OtherClass
{
MyClass[] cls = null;

public void DoSomething()
{
int a = 3000;
cls = new MyClass[a];
}
}

class program
{
OtherClass other = new OtherClass();

public int main()
{
other.DoSomething()
}
}

When running on Debug , this code works as expected, but on Release I get
an
OutOfMemoryException allocatting the array on "cls = new MyClass[a]" when
calling "DoSomething"

Can someone help me to solve it?

Thanks in advance

Fernando

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.