> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/perl6-rosettacode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/perl6-rosettacode/programming_tasks/f/find_limit_of_recursion.md).

# Find limit of recursion

Maximum recursion depth is memory dependent. Values in excess of 1 million are easily achieved.

```perl
my $x = 0;
recurse;

sub recurse () {
   ++$x;
   say $x if $x %% 1_000_000;   
   recurse;
}
```

When manually terminated memory use was on the order of 4Gb:

```
1000000
2000000
3000000
4000000
5000000
6000000
7000000
8000000
9000000
10000000
^C
```
