Opendistro crash when creating large number of rolesmapping with many users

I am trying to synchronize Opendistro Elasticsearch with an existing content database. The database has many roles around 50K and each may have up to 10K users. I tried to test the worst case by creating 50K roles and 50K rolesmapping each with 10K users. First it takes a very long time and then fails (out of memory exception).

What is the maximum threshold for roles and rolesmapping? How to resolve such situation? Any alternatives?

Thanks,
Hasan