The memory usage scale with the amount of files. This means that if there are too many files it will run out of memory and crash. This occurred in T428162: Make declarations for Category:Items with VRTS permission confirmed. That category had 1.8 M files. At the moment restarting won't help since that will run the same amount of files again.
Possible solutions include:
- Tagging the prepared declarations in the database in "chunks" (of say 100,000 each). Running each of them should be fine memory-wise. This would also have the advantage of not needing to re-check all the failed declarations it a batch needs to restart. However it would add a lot more jobs to the already long job list, which makes it more cumbersome.
- Implement chunking large declaration lists when declarations are made. This would require a bit of code restructuring. Things could get a bit tricky to make sure that things are logged correctly.