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

x
?
Solved

out of stack space

Posted on 2002-05-20
10
Medium Priority
?
209 Views
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
0
Comment
Question by:sureshrao72
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 22

Expert Comment

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

Example:

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

10
  on error goto TestLineNumbers_Err

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

30
  for i=1 to len(dataline)
40
    temp = mid$(dataline,i,1)
    if temp = "a" then
50      debug.print "A"
    else
60      debug.print temp
    endif
  next i
  exit sub
TestLineNumbers_Err:
  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.
0
 
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

Thanks,
Anthony
0
 
LVL 3

Expert Comment

by:adg
ID: 7022998
When you get the error, can you use the view call stack option to see what happened?
0
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

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

' In your code
IF GF.IDE Then
   On Error GoTo 0 ' Allow to crash when debugging
Else
   On Error Goto ErrorTrap
End If

' now perform your tasks.....


ErrorTrap:
  ErrNum = Err.Number
  ErrDesc = Err.Description
  ErrLine = Erl
  IF GF.IDE Then
      On Error GoTo 0 ' Allow to crash when debugging using the IDE
  Else
     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

'Example:
' 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
    Err.Clear
    Debug.Print 1 / 0
    If Err.Number <> 0 Then
        mIDE = True
    Else
        mIDE = False
    End If
    mIDEDone = True
End If

IDE = mIDE

End Function
0
 
LVL 17

Expert Comment

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



MyStrangeLoop:

'do some code

Gosub MyStrangeLoop

' never gets here
' do some more

Return

0
 
LVL 17

Expert Comment

by:inthedark
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

0
 
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

Anthony
0
 
LVL 22

Expert Comment

by:rspahitz
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.)
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7057643
rspahitz,

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

Anthony
0
 

Author Comment

by:sureshrao72
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.

suresh
0

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