This is very hard to troubleshoot and it will need some work to isolate the problem.
Could you try to extract the minimal part of the code from your template to a new one?
Write some kind of script to render multiple reports from this template and see if it has still the error behavior.
And if you get to this, share the template with us so we can take a look?
You can email it to me if it is confidential.