473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Arrays and OutOfMemoryException

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
2 3255


"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ryan Seghers | last post by:
I've got a program that has no user interface (like a service but not actually a Windows Service yet) in which I'd like to handle OutOfMemoryExceptions. I'd at least like to log the failure before...
0
by: Per Bergland | last post by:
After many woes, I finally managed to get a stack dump of my System Service (written in C#) that insists on crashing when launched at system boot time (see below on how to get this dump - I...
3
by: Michael | last post by:
I have a problem with catching the OutOfMemoryException in a managed C+ application. When creating small objects on the managed heap neithe the catch handler for OutOfMemoryException nor the...
1
by: Ripul Handa | last post by:
Hi We are running IIS 5.0 cluster with cisco local director. We are running a website on 2 webservers and I have been observing that from past few days we have are getting this error message of...
1
by: SMG - Idealake | last post by:
Hi all, I am getting following error on my error, what could be the reason? Exception of type System.OutOfMemoryException was thrown. Description: An unhandled exception occurred during the...
2
by: Dave | last post by:
We just started getting this error message in our application today (stack trace below). From the OutOfMemoryException, I'm guessing it could be a memory leak. I'm making sure I'm closing all my...
1
by: Ashkan Daie | last post by:
Hi All, When trying to install a performance counter via InstallUtil I get the following exception: Creating performance counter category Enterprise Library Caching. An exception occurred...
13
by: Venkatachalam | last post by:
Hi, In my application I have text(flat) file as input and I have to generate an XML file. The maximum input text file size can be 900MB and gererated xml may result 2+ GB. Based on the first...
6
by: chad | last post by:
assuming I have 2GB memory. And 1.5GB available. dim c1(,) as byte redim c1(1000, 1024*1024) throws system.outofmemoryexception. I'm like... huh? Initially I thought a lot of space is taken...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.