Rhyono Posted December 12, 2012 Share Posted December 12, 2012 My script checks some things every few seconds, and it can run for many hours. After about 4 hours, I got a recursion error from PixelGetColor. Is it just reaching a limit on the number of times it finds it acceptable to do it, or is it actually finding a memory leak? If it's the former: can I shut off recursion limits? Link to comment Share on other sites More sharing options...
BrewManNH Posted December 12, 2012 Share Posted December 12, 2012 You are reaching the recursion limit and there's no way to shut it off. Your script is written poorly and needs to be fixed because whatever you're doing is causing it to crash. 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 GudeHow 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 More sharing options...
Exit Posted December 12, 2012 Share Posted December 12, 2012 If you would show your code, we might help you. App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Mat Posted December 12, 2012 Share Posted December 12, 2012 (edited) I'm guessing somewhere you are doing something like: Func CheckSomething() PixelGetColor(...) Sleep(A bit) CheckSomething() EndFunc That kind of code pattern is the most likely way you'd hit the recursion limit. It's very easy to replace with a single loop, which would be the correct way to do it. Edit: You are actually pretty close when you say its a memory leak. Every time you call a function its added to the stack, and when you return it is popped off the stack. If you keep calling functions the stack just grows, never being unrolled (like a memory leak: allocating but not de-allocating). Edited December 12, 2012 by Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
Rhyono Posted December 12, 2012 Author Share Posted December 12, 2012 @Mat It does quite a bit more than that, but that is the basic structure. Switching it to a While would be easy enough; I just figured I'd get the recursion error either way. Link to comment Share on other sites More sharing options...
Mat Posted December 12, 2012 Share Posted December 12, 2012 @Mat It does quite a bit more than that, but that is the basic structure. Switching it to a While would be easy enough; I just figured I'd get the recursion error either way.A while loop is what we would call iteration. Generally iteration is preferred: There is only a finite stack (hence your recursion limit), and at a low level there is a lower overhead (though I wouldn't worry about this in AutoIt).Recursion is generally the option you use when iteration doesn't work. When working with nested structures (binary trees, linked lists etc.) which aren't common in AutoIt. Sometimes recursion can be a lot prettier than iteration as well. AutoIt Project Listing Link to comment Share on other sites More sharing options...
Developers Jos Posted December 12, 2012 Developers Share Posted December 12, 2012 @Mat It does quite a bit more than that, but that is the basic structure. Switching it to a While would be easy enough; I just figured I'd get the recursion error either way.This really means you still don't understand the basics of iterations and recursion and have a logic problem in your script. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
gruntydatsun Posted December 13, 2012 Share Posted December 13, 2012 Example using a while loop: ==================== There is a drip in the ceiling and you deploy clone 1 catch the drip When the next drip falls, clone 1 catches it and so on. After a thousand drips, you still only have one clone in the room. Example using recursion: ==================== There is a drip in the ceiling and you deploy clone 1 to catch the drip When the next drip calls, clone 1 deploys another clone called clone 2 to catch this drip. Meanwhile clone 1 just stands around taking up room. When the next drip falls, clone 2 calls another clone into the room to catch it (clone 3) Meanwhile clone 2 just stands around taking up room. This repeats until your room is stacked to the ceiling with clones and you can't fit anymore in. Sweet example Link to comment Share on other sites More sharing options...
Rhyono Posted December 13, 2012 Author Share Posted December 13, 2012 @Jos "Still" refers to the present; prior to your lovely snide remark, Mat already did a good job of explaining, and after your remark gruntydatsun did as well. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now