473,386 Members | 1,823 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,386 software developers and data experts.

No stack trace for System.OutOfMemory

Instances of SystemOutOfMemoryException do not contain a stack trace. Easy
test to verify this:

class OOM
{
public static void Main() {
try {
Object[, ] arr = new Object[100000000, 10000000];
} catch (Exception ex) {
dumpEx(ex);
}
}

private static void dumpEx(Exception ex) {
Console.WriteLine("Exception occurred");
Console.WriteLine(ex);
String s = ex.StackTrace;
if (s == null)
Console.WriteLine("Stack trace is null");
else
Console.WriteLine("StackTrace length is " + s.Length);
}
}

Output:

Exception occurred
System.OutOfMemoryException: Exception of type System.OutOfMemoryException
was thrown.
Stack trace is null

This makes debugging these exceptions tricky, to say the least. I wound up
having to track down where the exception was being generated with
WriteLines. I know that you can trap these is Visual Studio as well, but
this one was touchy (it turned out to be a synchronization problem) and the
performance degradation from running an ASP.NET program inside Visual Studio
made it stop happening. Two questions:

1. Are there any tricks that I'm missing for debugging these more
effectively?

2. Can we expect to see stack traces in some future release?
Nov 15 '05 #1
3 5407
OutOfMemory exceptions sometimes occur because there's too much in the call
stack (i.e. if a function unconditionally recursively calls itself). In
that situation, the call stack IS the reason for the OutOfMemory exception,
and it wouldn't really make sense to have it available for examination.
Knowing which function caused the error is generally enough (I would think).
However, don't see any reason why a stack trace can't be supplied for the
error you're generating in the example. Sorry I don't have an answer for
you, just though I'd offer my insight.

Chris LaJoie
"Mike Schilling" <ms*************@hotmail.com> wrote in message
news:Ob**************@TK2MSFTNGP11.phx.gbl...
Instances of SystemOutOfMemoryException do not contain a stack trace. Easy test to verify this:

class OOM
{
public static void Main() {
try {
Object[, ] arr = new Object[100000000, 10000000];
} catch (Exception ex) {
dumpEx(ex);
}
}

private static void dumpEx(Exception ex) {
Console.WriteLine("Exception occurred");
Console.WriteLine(ex);
String s = ex.StackTrace;
if (s == null)
Console.WriteLine("Stack trace is null");
else
Console.WriteLine("StackTrace length is " + s.Length);
}
}

Output:

Exception occurred
System.OutOfMemoryException: Exception of type System.OutOfMemoryException
was thrown.
Stack trace is null

This makes debugging these exceptions tricky, to say the least. I wound up having to track down where the exception was being generated with
WriteLines. I know that you can trap these is Visual Studio as well, but
this one was touchy (it turned out to be a synchronization problem) and the performance degradation from running an ASP.NET program inside Visual Studio made it stop happening. Two questions:

1. Are there any tricks that I'm missing for debugging these more
effectively?

2. Can we expect to see stack traces in some future release?

Nov 15 '05 #2
OutOfMemory exceptions sometimes occur because there's too much in the call
stack (i.e. if a function unconditionally recursively calls itself). In
that situation, the call stack IS the reason for the OutOfMemory exception,
and it wouldn't really make sense to have it available for examination.
Knowing which function caused the error is generally enough (I would think).
However, don't see any reason why a stack trace can't be supplied for the
error you're generating in the example. Sorry I don't have an answer for
you, just though I'd offer my insight.

Chris LaJoie
"Mike Schilling" <ms*************@hotmail.com> wrote in message
news:Ob**************@TK2MSFTNGP11.phx.gbl...
Instances of SystemOutOfMemoryException do not contain a stack trace. Easy test to verify this:

class OOM
{
public static void Main() {
try {
Object[, ] arr = new Object[100000000, 10000000];
} catch (Exception ex) {
dumpEx(ex);
}
}

private static void dumpEx(Exception ex) {
Console.WriteLine("Exception occurred");
Console.WriteLine(ex);
String s = ex.StackTrace;
if (s == null)
Console.WriteLine("Stack trace is null");
else
Console.WriteLine("StackTrace length is " + s.Length);
}
}

Output:

Exception occurred
System.OutOfMemoryException: Exception of type System.OutOfMemoryException
was thrown.
Stack trace is null

This makes debugging these exceptions tricky, to say the least. I wound up having to track down where the exception was being generated with
WriteLines. I know that you can trap these is Visual Studio as well, but
this one was touchy (it turned out to be a synchronization problem) and the performance degradation from running an ASP.NET program inside Visual Studio made it stop happening. Two questions:

1. Are there any tricks that I'm missing for debugging these more
effectively?

2. Can we expect to see stack traces in some future release?

Nov 15 '05 #3

"Chris LaJoie" <ch***@etriptrader.com> wrote in message
news:Ow**************@TK2MSFTNGP09.phx.gbl...
OutOfMemory exceptions sometimes occur because there's too much in the call stack (i.e. if a function unconditionally recursively calls itself). In
that situation, the call stack IS the reason for the OutOfMemory exception, and it wouldn't really make sense to have it available for examination.
Sure, and it's also possible that the heap is exhausted so there isn't room
to construct a stack trace.
Knowing which function caused the error is generally enough (I would think). However, don't see any reason why a stack trace can't be supplied for the
error you're generating in the example.


Nor do I.
Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Markus Dehmann | last post by:
What's the best way to implement an exception stack trace? What I want is sth like printStackTrace() in Java. It could look like this: Car.cpp:381:runtime_exception:Could not find the brake...
7
by: JP | last post by:
I managed to get error checking does in my application. In using the Exception object I can get all the information I need about the error like the line # where the exception occurred. IS there a...
0
by: Mike Schilling | last post by:
Instances of SystemOutOfMemoryException do not contain a stack trace. Easy test to verify this: class OOM { public static void Main() { try { Object arr = new Object; } catch...
0
by: Mike Schilling | last post by:
I have some code that calls methods reflectively (the method called and its parameters are determined by text received in a SOAP message, and I construct a map from strings to MethodInfos). The...
2
by: Gal Moshitch | last post by:
Hi, I developed an application which writes errors to the event viewer whenever an exception is thrown (this is done at the application_error event). Except for the exception message, I also...
2
by: Lasse Vågsæther Karlsen | last post by:
If I got the following code: try { // something that might throw an exception } catch (Exception ex) { // Log contents of ex here throw;
2
by: news.microsoft.com | last post by:
Hi all. If I wanted to write something so that, when an exception was thrown, and the stack unwound, the stack trace was captured with the values of the parameters (instead of just the parameter...
5
by: Mr. SweatyFinger | last post by:
WHY CAN'T THE CLOWN -HOLES WHO WROTE ASP.NET PROVIDE AN ERROR LINE NUMBER??? HONEST TO SH@THOLE PETE Server Error in '/New Folder (7)' Application....
3
by: Dave Anson | last post by:
I have a custom exception and I want to write the information to the event log, including the Stack Trace. I can create the message and write to the event log no problem, but the Stack Trace is...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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.