Query event on all org's events is slow,and cause out of memory

Maybe if you try to query org’s events into smaller chunks rather than running it all at once. What are the specifications of your device (RAM, tomcat version, postgres…etc)? Would it be possible to increase the heap space to Xms12000m,Xmx12000m

There’s been a similar issue but it was for importing events; however, I’d say to see if @Zubair’s suggestion will work here as well: