Jump to content

What is the MAX Recursion level in AutoIt?


Recommended Posts

The classic "Recursion level has been exceeded - AutoIt will quit to prevent stack overflow" error in AutoIt. I made these 2 scripts to test the Recursion levels in AutoIt:

This is the first script I made:

Global $iRecursionLevel = 0

X()

Func X()
    Y()
EndFunc

Func Y()
    $iRecursionLevel += 1
    ConsoleWrite($iRecursionLevel & @CRLF)
    X()
EndFunc

It made ran until the $iRecursionLevel exceeded 1899. The next script I made however, made till 3799!:

Global $iRecursionLevel = 0

X()

Func X()
    $iRecursionLevel += 1
    ConsoleWrite($iRecursionLevel & @CRLF)
    X()
EndFunc

 

So, my question is simple, What is the MAX Recursion level in AutoIt?? Thanks in Advance :).

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

  • Moderators

See here for an explanation from Trancexx in response to a similar question (easily found through a forum search, btw). Scroll up one or two to see the limits found in testing by Willichan

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

It depends on the options Jon uses to compile the executor, the OS architecture (x86 or x64), the stack size used by outer functions before recursion and the stack size needed by every recursive invokation. AFAICT.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

4 hours ago, TheDcoder said:

Hmm.... So there is no hard coded limit then... Makes my job harder now :P.

 

It shouldn't be any harder now than it was before you asked the question. The thing is, if you can avoid recursion you should. Unless you have it planned out in detail you're going to hit a limit eventually.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

@BrewManNH I have planned the recursion in detail but there is a 0.001% chance that it will hit that limit (As the limit is artificial). I haven't implemented this idea in my project yet. So lets just see how it goes :).

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

The limit isn't "artificial" at all. It's simply there.

I think it should be changed at runtime by use of a new pragma.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Why not post a feature request for such feature?

It may even be implemented with a small set of keywords, like this:
#StackDepth=[small,MEDIUM, large, giant]
with small meaning a low amount able to minimize memory footprint for simple scripts (e.g. shorthand helpers, services, ...) with little or no recursion,
MEDIUM (default) meaning what we currently have (might be a little more),
large meaning, say 8Mb (I make the value out of blue),
giant meaning a very large stack, say 512 Mb or something topped by available memory.

Also, official guidelines for estimating the amount of stack consumed by function call and parameters would help tailoring what is needed.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

1 minute ago, jchd said:

Why not post a feature request for such feature?

Why no do it yourself? I don't know much about stack as you do :). I will be sure to follow that ticket :D.

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

I haven't used AutoIt myself for many years, hence I don't have any kind of need. Posting a feature request about something that I don't use at all would be an exageration. Bug reports aren't in the same category as bugs can be detrimental to unsuspecting users.

It's up to you, actual users, to make sensible proposals to improve the usefulness of your pet tool. Me, I'm just an old crow perched on a branch, looking around.

So go ahead and use the material of this thread to make a good proposal.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

instead of trying to change AutoIt (whether that would be an improvement or not) i would consider this approach:

AutoIt is a practical scripting language. if you are interested in theoretical limits, go somewhere else. use C++ for example, in which you can manage the memory yourself (after you've spent the months it takes to master that, anyways...). if you are concerned with hitting the theoretical limit in practice, then modify your code. either plan your recursion well, or avoid it altogether - there are decent iterative methods that can probably get your job done.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

The internal stack has to be reserved before interpretor start and can't reasonably be changed once instructions have been executed (in the general case). So it isn't suitable to be able trigger the feature in the middle of user code as a normal instruction. Think of it like #NoTrayIcon or #RequireAdmin: place them at very top of script or not at all.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

@jchd Ah! Ok, now I understand...

@orbs The recursion I am working on is a little different, its not iterating over something. Of course, I have it well planned too :D.

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

11 minutes ago, TheDcoder said:

The recursion I am working on is a little different

care to elaborate? just for our curiosity...

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

1 minute ago, orbs said:

care to elaborate? just for our curiosity...

It is something which is hard to explain... It has something to do with my IRC Bot. I can explain it in detail if you were to visit us there :D.

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

no thanks, i had my fill with chats at work. bl**dy hell, i once witnessed two guys sitting 6 feet away of each other starting a chat session.

the reason i'm asking is that when you describe your goal, someone here - as often happens - may offer an alternative.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...