I avoided "OPTIMIZE" since it caused OOM issues and I was fine without the index which looks like a double edged sword : ).
If you don’t need the indexes, you can disable them when running db:optimize, and setting textindex and attrindex to false.
QQ, Is there some stat on how much RAM is needed for maintaining basex DB
of size 'X'GB (with regular inserts and delete) so that "optimize" could be called without worrying about OOM?
Hardly possible to say in general; it depends a lot on the “regular inserts and deletes” ;) If you cannot solve the optimization problem, feel free to share the OOM stack trace with us.