I also have to say that it happens the same if java memory is the default or custom
It is, but experimenting a bit more I have similar issues without any redstone or command block, but the freeze is not permanent and it lasts some minutes, repeating in a continuous cycle.
I also have to say that it happens the same if java memory is the default or custom