RE: StackOverflowException.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
>
>
>
.



Relevant Pages

  • Re: Doc/View question
    ... elements in the array to get how many bytes of stack space it requires. ... sequence of bytes that is long enough to hold the entire contents of the array. ... data type" for this purpose! ... So then it appears that I can put structs of different member types into CArray ...
    (microsoft.public.vc.mfc)
  • Re: StackOverflowException.
    ... Moved the thread to microsoft.public.dotnet.framework as "Stack Memory Leak ... > information is stored in a local byte array of about 4k. ... > mistaken in thinking that assigning a byte array to an object property ... > If assigning a byte array to a class property DOES ...
    (microsoft.public.dotnet.framework)
  • Re: I dont understand the definition of DOES>
    ... on stack on code entry). ... You can use DOES to make ARRAY and then use ARRAY ... CREATE CELLS ALLOT ... First you'd make the code that will execute on the child word. ...
    (comp.lang.forth)
  • Re: a kind of an assumed-shape array leads to a sig11
    ... extent of an array in a subroutine bad practice? ...    end module bar ... default stack size limits on many current systems. ... Some compilers have options to avoid putting large automatic arrays ...
    (comp.lang.fortran)
  • Re: Globally declared arrays
    ... I noticed that my colleague was declaring local arrays on the stack, ... What is a "global array on ...
    (comp.lang.c)