What do the rules do ? if you insert a lot of objects in the then part, it can consume memory and the heap. At the end, you can have an OutOfMemory
You should first increase the heap size (4-5 GB or more ) and you will see what happens
I am not inserting much objects and I am retracting every object we insert. Increasing heap size is not a good solution for this I think, because in my case there may be more objects, not just 500.