1

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?

AJ-
  • 109
  • 1
  • 2
  • 10
  • one thing which i forgot in the question is that i cannot increase the heap size as it is already 3GB and its further increase cost is high. – AJ- Sep 07 '15 at 03:02
  • 5
    Related to http://stackoverflow.com/questions/2679330/catching-java-lang-outofmemoryerror – Codebender Sep 07 '15 at 03:09
  • Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a [mcve] – durron597 Sep 07 '15 at 03:31
  • https://en.wikipedia.org/wiki/Lakh 100.000 – Thilo Sep 07 '15 at 04:24
  • Try to not produce the whole Excel file in memory (and certainly don't load the whole result set into memory all at once). There must be a way to stream both. – Thilo Sep 07 '15 at 04:26

0 Answers0