Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


out of stack space

Posted on 2002-05-20
Medium Priority
Last Modified: 2010-05-02
This is a repetitive question, but still im not able to solve. I get run time error 28, out of stack space.
The solution is remove recursive loops. I have lot of small functions, i dont know exactly where the error occurs. Its does'nt show the line numbers.. How can i trace the line number in dll
Question by:sureshrao72
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +2
LVL 22

Expert Comment

ID: 7022667
You can add line numbers if you want, since they are still supported, but simply deprecated and probably removed in .NET.


Private sub TestLineNumbers()
  dim somevar as integer
  dim anothervar as string

  on error goto TestLineNumbers_Err

  do while not eof(1)
    line input #1, dataline

  for i=1 to len(dataline)
    temp = mid$(dataline,i,1)
    if temp = "a" then
50      debug.print "A"
60      debug.print temp
  next i
  exit sub
  msgbox "Error occured somewhere after line " & erl
end sub

The line numbers can be placed before anyline, either on their own, or as a prefix to a line, and they can range from 1 to 32767.
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7022702
Please maintain your open questions:

Questions Asked 8
Last 10 Grades Given B B B C  
Question Grading Record 4 Answers Graded / 4 Answers Received


Expert Comment

ID: 7022998
When you get the error, can you use the view call stack option to see what happened?

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

LVL 17

Accepted Solution

inthedark earned 120 total points
ID: 7023214
I would propose a small improvement rspahitz's idea:

' In your code
   On Error GoTo 0 ' Allow to crash when debugging
   On Error Goto ErrorTrap
End If

' now perform your tasks.....

  ErrNum = Err.Number
  ErrDesc = Err.Description
  ErrLine = Erl
  IF GF.IDE Then
      On Error GoTo 0 ' Allow to crash when debugging using the IDE
     On error resume next ' Stop looping back to ErrorTrap
  End If

now handle fault etc......


Create a class module named zGF. Place all your handy subs and functions in the module. (You may already do this.)

In you app. create a module and include:

Global GF as New zGF

Now if you type "GF." you get a list of your handy functions

==========Here is the code for the zGF module

Option Explicit

Dim mIDEDone As Boolean
Dim mIDE As Boolean

Public Function IDE() As Boolean

' Returns True if running in debug (IDE) mode
'         False if running in an EXE

' If ADO.IDE Then Stop

If Not mIDEDone Then ' See below
'To make this function work you need the following in your
' class declarations:
'Dim mIDEDone As Boolean
'Dim mIDE As Boolean

    ' just do this first time round then store the result
    On Error Resume Next
    Debug.Print 1 / 0
    If Err.Number <> 0 Then
        mIDE = True
        mIDE = False
    End If
    mIDEDone = True
End If


End Function
LVL 17

Expert Comment

ID: 7023216
You can also get out of stack space if you use Gosub like:


'do some code

Gosub MyStrangeLoop

' never gets here
' do some more


LVL 17

Expert Comment

ID: 7023233
DLL's are hard to debug, especially when running on a web-server, you don't get to see the error message so you must never allow the software to crash.

I always dump all errors into a log file formatted with HTML and get the error logging routine to send me an e-mail message with the error detail.  The idea is that you can repair the fault before the boss finds out. Also its important to log the user ID so you know who to apologize to.

adg's idea is good for debug mode but in a live environment it won't help.

At the start of all Subs and functions you can place code like.

Function MyFunction()
Dim Stage as Long
IF LE Then Arriving "MyFunction"

Stage = 1000

' do some code

Stage = 1010

If TimeToQuit Then
   If LE Then Leaving ' always call before exit
   Exit Function
End if

Stage = 1020

If LE Then Leaving ' always call before exit

End Function

You can use an INI file switch to set LE = True if you require application debugging. The Arriving sub adds the sub name to a global stock of subs and Leaving reduces the stack by 1.  The advantage of this is tha you can call a global error handle which records all of the details of any errors and sends you an email.

HandleError "Stage:"+cstr(Stage)+ " - " + ErrDesc + " ~ "+SQL ' etc

LVL 75

Expert Comment

by:Anthony Perkins
ID: 7057208
You have to wonder, but than it is not like you were not warned. At least the questioner is consistent:

Questions Asked 9
Last 10 Grades Given B C C B B B C  
Question Grading Record 7 Answers Graded / 7 Answers Received

LVL 22

Expert Comment

ID: 7057603
sureshrao72, as you might guess, the surest way to fail to get responses from experts is to not participate in the discussion and then offer bad grades without explanation.

If you would like to correct the grade, please add a zero-point question in the customer support topic area and reference this, any, or all of your questions and ask that the grade be adjusted.

Meanwhile, good luck getting quality help from the experts at this site.  (It's not that you can't give lower grades, but they should always be explained as to why they are not "A"s.)
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7057643

What is so incredibly asinine about this is, is that it really only hurts the questioner, especially when no explanation is offered.


Author Comment

ID: 7057664
guys i dont really understand certain things in this site.

First, Im not able to close my question even if i accept an answer.

Second, im not able to increase my points, eventhough i closed all accepting an answer.


Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question