Preface:- I have a export functionality in my application, which gives me the output in excel. The application in which i am working is a very restricted application in a sense that you can't do much by your self and you have to rely on the application architecture.
Problem Statement:- There are certian scenarios in which my application exports around 2 lacs records from the database. I make query and i pass it on to a framework, which in itself executes it and pass me a list carrying result.I cannot excess the framework. Sometimes when the result size is too much,for example 2lacs, the application throws java heap size error.
Question:- My question is how can i check if my heap size is crashing and before JVM throws error, i should be able to check and stop it's execution and throw an customized message to the user. Can i start a thread for that?