Number of Gradle Worker Main and MaxWorkers Configuration

We currently have an issue with the numbers of Gradle workers as the build ends up running into a memory issue on the developer’s machine.
The number of workers is limited to 4 (org.gradle.workers.max=4), but when the build runs, 8 and more (30) workers “GradleWorkerMain” are active, depending on the called task.
How can we limit the number of active worker threads? Developers can not really work on a local machine.

Thanks for any help.