What is a “tight loop”?

前端 未结 8 711
说谎
说谎 2020-12-01 06:56

I\'ve heard that phrase a lot. What does it mean?

An example would help.

8条回答
  •  甜味超标
    2020-12-01 07:38

    From experience, I've noticed that if ever you're trying to do a loop that runs indefinitely, for instance something like:

    while(true)
    {
        //do some processing
    }
    

    Such a loop will most likely always be resource intensive. If you check the CPU and Memory usage by the process with this loop, you will find that it will have shot up. Such is the idea some people call a "tight loop".

提交回复
热议问题