Any chance you have min_doc_count set to 0, have a large range, and have a small interval? I believe we can run out of memory in that case. I merged https://github.com/elastic/elasticsearch/pull/72081 recently to stop it from running out.
If you have something else I'd love to hear about it! Running out of memory is always a bug. Might be one we've fixed, but yeah.
The best way to file an issue is to reproduce it on an empty install with a bash script running curl. Or the kibana dev console. If you can do that the stack trace on the oom would give us a hint. But sometimes it takes detective work to from there.