Abrar,
This error means you are trying to process too many records at once and the Java Virtual Machine runs out of memory. One way to get around this error is to process the records in batches. A development pattern I have used to do this is to add some attributes to the entity that I am processing:
In the microflow that processes these records,
After making those changes, you can run the microflow as many times as needed to process all records.
Hope that helps,
Mike