For the first part see this post. In my model I have one object with 85 child objects. All references are set that when the father is deleted all the childs will also be deleted. The problem is that deleting the father results in a java heap space error. I first tried to delete all the childs seperately through batches (see my first post about deleting a lot of records). I presumed that after this I could delete the father. Problem is that I now run out of garbage collection: java.lang.OutOfMemoryError: GC overhead limit exceeded. I tried already to delete this single father entity in Java (with batch size 1). But deleting this one object (with the 85 now empty children) still throws the garbage collector error. How can I solve this?
Use separate database transactions for each set of parents objects. Even with batch size 1, if you don't use separate transactions you can still have memory errors. Try to log after each batch remove. Does it fail before the fist logging? Or does it fail after a while? In the last case separate transactions will do it (see my answer here).