Solved

out of stack space

Posted on 2002-05-20
10
180 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
 
LVL 17

Accepted Solution

by:
inthedark earned 60 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now