This happens when you have to many objects (>64000 per session) that doesn't go out of scope. This commonly happens if you have an infinite recursion.
If this isn't the problem it might help to make intermediate
commits[
^]. Or having more than one transaction.