RE: StackOverflowException.
- From: "Cowboy (Gregory A. Beamer) - MVP" <NoSpamMgbworld@xxxxxxxxxxxxxxxxxx>
- Date: Mon, 25 Apr 2005 18:07:12 -0700
Streams are meant to be used as a transport mechanism from one endpoint to
another. In most systems, the final endpoint is a persistant store, not a
perpetual cache. The array should be held on the heap, so this should not be
a problem, but you may be eating up the stack with object references that
never go out of scope. That is where I would check.
---
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
***************************
Think Outside the Box!
***************************
"Robert Bouillon" wrote:
> I have a StackOverflowException that's NOT caused by a recursive function.
> I'm having a hard time with this exception as it takes about an hour to
> reproduce, and I'm not sure what's causing it.
>
> I have a serial stream class that reads bytes from a serial port. The
> information is stored in a local byte array of about 4k. When I'm done
> processing the data, the byte array is assigned to an object property that
> serves to retain a record of the bytes transferred. I think this may be the
> problem.
>
> I know that locally declared byte arrays are stored on the stack. Am I
> mistaken in thinking that assigning a byte array to an object property boxes
> the array (Because the object exists on the heap)? If so, then this is my
> problem. How do I box the array while keeping it strong-typed?
>
> If assigning a byte array to a class property (on the same thread) DOES box
> the array, then I'm at a loss to the problem. Are there any tips or tricks
> to determining what exactly is being stored on the stack?
>
> Of course because error handling requires stack space, and my stack is
> invalid due to an overflow, it's very difficult trying to track down this
> bug.
>
> EXAMPLE CODE (Short version: not actual code. Just to demonstrate how my
> code handles the array):
>
> do{
> byte[] buffer = new byte[4196];
> p_Stream.Read(buffer,0,4196);
> DoStuff(buffer);
> DataRecord dr = new DataRecord();
> dr.Data = buffer;
> } while(i++<500)
>
> Thanks
> --ROBERT
>
>
>
.
- Follow-Ups:
- Re: StackOverflowException.
- From: Robert Bouillon
- Re: StackOverflowException.
- References:
- StackOverflowException.
- From: Robert Bouillon
- StackOverflowException.
- Prev by Date: Postback doesn't work with validators
- Next by Date: Windows Service - Share Instance without Remoting
- Previous by thread: Re: StackOverflowException.
- Next by thread: Re: StackOverflowException.
- Index(es):
Relevant Pages
|