Category: 

What Is an Infinite Loop?

Article Details
  • Written By: M. McGee
  • Edited By: Lauren Fritsky
  • Last Modified Date: 28 September 2014
  • Copyright Protected:
    2003-2014
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
Atlanta's Hartsfield-Jackson International Airport is the world's busiest with 94 million passengers annually.  more...

October 26 ,  2001 :  US President George W. Bush signed the USA PATRIOT Act.  more...

An infinite loop is a condition that causes a computer program to continue executing a command without end. This is typically due to one of three causes: the program has no end condition, the program’s end condition is unattainable or a repeat command causes a program to continuously restart. Most of the time, an infinite loop will cause a computer to drastically slow down or even lock up. In early computers, these loops would often necessitate a restart, but modern operating systems will often catch them and terminate the program before they get out of hand.

Infinite loops exist within programming; other uses of the term are usually incorrect. In most cases, infinite loops are not the end goal of the program, and a problem exists somewhere in the code that causes the condition to occur. Each of the three main cases of an infinite loop is completely programming- and software-based.

When a program has no end condition, it will continue to execute its last set of instructions without end. In many cases, this will result in the program locking up as it waits for some final instruction that will never come. Other times, the last instruction given to the program was executing an instruction or processing a command. In these cases, it will continue to do these things without end. This will cause the computer to slowly fill with repeated commands from the infinite loop until the entire system is working on a problem with no end.

Ad

A similar situation exists when a program’s end condition is unattainable. In this case, the program can end, but it never will. The problem with the end point may be in the programming, or it may be a computer error that causes the condition. For example, if a program asks for a specific piece of information from a specific location, a programming error would be that the information is stored in a different spot. On the other hand, if the information is going to the program, but is interrupted due to interference from the user or another program, it may simply never arrive.

The last cause of an infinite loop is completely programming-based. Someplace within the programming is a command that tells the program to repeat something. While these commands are common, conditions should never allow the repeated command to come back to the initial repeat. If this happens, the program will execute a command, hit the repeat statement, then execute the command again, then repeat again, and so on. These loops are the most likely to be deliberately programmed, often as part of a piece of malware.

Ad

More from Wisegeek

You might also Like

Discuss this Article

Post your comments

Post Anonymously

Login

username
password
forgot password?

Register

username
password
confirm
email