Main > Knowledge Base > Developer resources > Development recommendations > 1C:Enterprise script > Infinite recursion > Developer resources > Development recommendations > 1C:Enterprise script > Infinite recursion > Developer resources > Development recommendations > 1C:Enterprise script > Infinite recursion

Infinite recursion

You can perform recursive procedure calls in 1C:Enterprise modules. The simplest recursion example is calling a procedure from itself. You can use recursive procedure calls for implementing various algorithms. For example, you can use this for iterating a query result by catalog hierarchy because the number of hierarchy levels is not known in advance.

When implementing a recursive call, you must provide a way to break out of recursion by some condition in order to avoid infinite recursion.

Note that each procedure call level uses a certain amount of memory. During infinite recursion, first the system stops responding due to multiple procedure calls, and then the memory overflow leads to application termination. The system cannot identify this as a module execution error because it cannot determine whether it is intentional behavior or an algorithm error. Therefore, in case of infinite recursion no script error messages are displayed but the application is terminated.

Also, note that infinite recursion can be caused not only by explicit procedure calls from itself but also by calling a handler that calls itself. For example, if the OnCurrentPageChange() handler includes a page change, this calls the OnCurrentPageChange() handler recursively. This leads to infinite recursion and application termination.

Next page: Messages displayed to users




© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.