Out of memory: Java Heap Space with mongodb-driver-core:4.6.1 with ReactiveMongoTemplate

It’s hard to tell. The only possibly relevant change I’m aware of is in the 4.0 upgrade notes:

The connection pool no longer enforces any restrictions on the size of the wait queue of threads or asynchronous tasks that require a connection to MongoDB. It is up to the application to throttle requests sufficiently rather than rely on the driver to throw a MongoWaitQueueFullException.

But if you weren’t getting any MongoWaitQueueFullException exceptions thrown from the 3.12 driver then that’s probably not it.

It might help the diagnosis along if you could reproduce this in a standalone application.