LibreOffice Draw not responding

I am using automation using java_uno/unoil/unoloader etc. libraries to generate flowchart using Draw. A lot of times there is no problem, and I can generate very large charts without any issue.

But then, sometimes I get a dialog saying SEH Exception, or sometimes the tool stops responding, and shows a dialog asking to close the application.

I am using version version.

Somewhere I read that renaming the user profile works, but this was happening even after I renamed the registrymodifications.xcu file.