On a second run here are the statistics:
Execution time: 1,713.649 seconds. Database queries: 511. Privacy checks: 503. Memory usage: 16,384 KB
So the problem is time (nearly 30 minutes) rather than memory (only 16 MB), but still not something practical in reality.