Re: StackOverflowException.
- From: "Robert Bouillon" <djwhizzard@xxxxxxxxxxx>
- Date: Tue, 26 Apr 2005 12:27:16 -0400
Moved the thread to microsoft.public.dotnet.framework as "Stack Memory Leak
in C#".
Please feel free to keep continue responding here if you wish.
--ROBERT
"Robert Bouillon" <djwhizzard@xxxxxxxxxxx> wrote in message
news:euuGOzbSFHA.3944@xxxxxxxxxxxxxxxxxxxxxxx
> 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
>
>
.
- References:
- StackOverflowException.
- From: Robert Bouillon
- StackOverflowException.
- Prev by Date: Image SQL type
- Next by Date: Urgent. Socket.BeginConnect doesn't work when is called from a separated thread
- Previous by thread: Re: StackOverflowException.
- Next by thread: cancelling a scroll event from a vScroolBar
- Index(es):
Relevant Pages
|