Go Premium for a chance to win a PS4. Enter to Win


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
  • 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?
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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 questions..by accepting an answer.


Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

772 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