473,804 Members | 3,649 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Arrays and OutOfMemoryExce ption

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.DoSomethi ng()
}
}

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

Can someone help me to solve it?

Thanks in advance

Fernando


Nov 17 '05 #1
2 3276


"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.DoSomethi ng()
}
}

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

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.

OutOfMemoryExce ption 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.DoSomethi ng();
Console.Read();
}
}

"Fernando Casero" <fe************ @speedy.com.ar> wrote in message
news:O7******** ******@TK2MSFTN GP12.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.DoSomethi ng()
}
}

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

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
4343
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 exiting, if possible. I understand that it probably takes some memory to continue operating, even just to write a message to an open file, but if the allocation that triggered the OutOfMemoryException was large then there probably really is a...
0
2782
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 couldn't find any info on how to do this). Here's the stack trace from cordbg: Unhandled exception generated: (0x04719c94) <System.Runtime.Remoting.RemotingException> _className=<null> _exceptionMethod=<null>
3
6010
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 UnhandledExceptio handler is called in an out of memory situation. Instead the applicatio writes 'Fatal out of memory' to the console and exits Is this a bug in the runtime or am I missing something Here is the example code #include "stdafx.h...
1
3455
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 and on Error Messag Remote IP:66.122.242.6 Host:216.211.212.2
1
4996
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 execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.OutOfMemoryException: Exception of type System.OutOfMemoryException was thrown.
2
3948
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 connections in the finally block but I'm not sure what I should be doing. As far as the "Unable to serialize the session state" error, this app has been running for days and this is the first I've seen this one as well. Any thoughts would be...
1
3900
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 during the Install phase. System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was
13
12957
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 column value from the text file, the row will be moved to any of those 23 DataTable which are created onfly. For eg. 01;- data for Table 1-
6
4299
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 up by GC. So, I up my memory to 4GB. Same thing.... So, I read microsoft documents on this type of exception. Doesn't help much. They were saying to try and keep arrays to 64KB. But, that's not much to work
0
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9569
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10318
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10302
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9130
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.