Re: Memory Leak?

Steve Johnson <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.advanced
Message-ID <[email protected]>
Likely, the problem is recursion.  Each call to DoEvents pumps messages,
which causes your VREADFIELDS function to be called from within itself.
Each call allocates another stack frame.  You'll eventually run out of stack
space and crash with a StackOverflowException.

--
Steve Johnson


On Mon, Dec 1, 2008 at 5:47 PM, Dave Vorgang <[email protected]
> wrote:

> I have the following code that simply loops until _KeyEntered >= 0.  The
> application works and the CPU in task manager shows 0.
>
> The problem I'm having is that the Mem Usage in Task Managers keeps
> incrementing at a fairly significant amount.  Why would it do that?
>
>  ''' <summary>
>    ''' This routine will loop until _KeyEntered is >= 0.
>    ''' _KeyEntered of 0 = Enter Key, 1 - 8 = Function Key, 9 = frmMain was
> Closed.
>    ''' </summary>
>    ''' <param name="comArea"></param>
>    ''' <returns></returns>
>    ''' <remarks></remarks>
>    Public Function VREADFIELDS(ByVal comArea As ComAreaDefinition) As
> Integer
>        _KeyEntered = -1
>
>        Do
>            System.Windows.Forms.Application.DoEvents()
>            Thread.Sleep(1)
>        Loop Until _KeyEntered >= 0
>
>        comArea.NumErrs = 0
>        comArea.LastKey = _KeyEntered
>
>        Return _KeyEntered
>    End Function
>
> Thanks,
>
> Dave Vorgang
> Senior Programmer / Analyst
> Medford School District - Information Technology
> (541) 842-1021
> mailto:[email protected]<BLOCKED::mailto:
> [email protected]>
>
>
> ===================================
> View archives and manage your subscription(s) at
> http://peach.ease.lsoft.com/archives
>

===================================
View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.