# I need a workaround on "Inifinite Loop detected"

**URL:** <https://forums.unrealengine.com/t/i-need-a-workaround-on-inifinite-loop-detected/1211847>\
**Category:** Blueprint\
**Tags:** unreal-engine, Blueprint, question\
**Created:** [June 27, 2023, 5:04am UTC](https://forums.unrealengine.com/t/i-need-a-workaround-on-inifinite-loop-detected/1211847 "2023-06-27T05:04:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![xianthryllis](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@xianthryllis](https://forums.unrealengine.com/u/xianthryllis)\
**Post date:** [June 27, 2023, 5:04am UTC](https://forums.unrealengine.com/t/i-need-a-workaround-on-inifinite-loop-detected/1211847/1 "2023-06-27T05:04:31Z")

</div>

Part of my blueprint needs to loop through an array of more than 700,000 elements. But, it already stops at the for-each loop, prompting the error “Infinite loop detected.”

I am trying to generate a point cloud so it is necessary that my program be able to generate at least more than 1 million points. I hope someone here knows a workaround on this one. Thanks in advance!

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/6/1/e61dc5571317e70c66f13669ff3ee2841e4f2602.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 27, 2023, 6:32am UTC](https://forums.unrealengine.com/t/i-need-a-workaround-on-inifinite-loop-detected/1211847/2 "2023-06-27T06:32:31Z")

</div>

A workaround would be to break the loop into numerous small steps and complete them in sequence. You can also:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/7/8/378c4386dfe95bf9de506deae02a42dc120a1a56.png)

---

<div class="post-metadata">

**Author:** ![xianthryllis](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@xianthryllis](https://forums.unrealengine.com/u/xianthryllis)\
**Post date:** [June 27, 2023, 7:19am UTC](https://forums.unrealengine.com/t/i-need-a-workaround-on-inifinite-loop-detected/1211847/3 "2023-06-27T07:19:30Z")

</div>

Hi, Everynone. Could you give me some tips how to break down the loops into smaller bits in blueprint? I don’t see any node that could help me do that.

Also, thank you for letting me know about the Project Settings option. I saw that my project has a limit of one million, but I still get the same error at 700,000+ points. Bumped it up to 2million and it’s still the same.

---

<div class="post-metadata">

**Author:** ![xianthryllis](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@xianthryllis](https://forums.unrealengine.com/u/xianthryllis)\
**Post date:** [June 27, 2023, 9:27am UTC](https://forums.unrealengine.com/t/i-need-a-workaround-on-inifinite-loop-detected/1211847/4 "2023-06-27T09:27:00Z")

</div>

Dear Everynone,

Thank you again for the tip. I tried to increase the maximum loop iteration value to 10 Million. I found out that it counts not only the per-loop iteration, the processes within the loop is also included toward the count to maximum number of iterations.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/9/5/a95f6f8e90c07c4a457e7cde016e96df6d69a0cd.png)

---

<div class="post-metadata">

**Author:** ![UnrealEverything](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@UnrealEverything](https://forums.unrealengine.com/u/UnrealEverything)\
**Post date:** [June 28, 2023, 6:06am UTC](https://forums.unrealengine.com/t/i-need-a-workaround-on-inifinite-loop-detected/1211847/5 "2023-06-28T06:06:13Z")

</div>

The runaway loop counter typically resets every tick. So one approach would be to spread processing into chunks over multiple ticks. Where does the input array to the foreach loop come frome? This can be a common mistake as the function providing the array will be called for each iteration as well. Try searching other threads with the same issue, not too long ago I spent a while answering one here [Absolute BS infinite loop error...](https://forums.unrealengine.com/t/absolute-bs-infinite-loop-error/836778/1)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [June 28, 2023, 7:03am UTC](https://forums.unrealengine.com/t/i-need-a-workaround-on-inifinite-loop-detected/1211847/6 "2023-06-28T07:03:38Z")

</div>

> The runaway loop counter typically resets every tick

Apparently, the UE5 sports this fancy thing I’ve never tried:

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/1/b/61bd712e62bc2251a41c6f4df8a24330fdb5c963.png)

Rather than doing ForEach for 1 gazillion elements, you’d take the 1/4 gazillion and do it 4 times.

* * *

Last time I tried to loop 1.000.000 in BPs, it was mostly crashing and freezing. More than usual, that is.
