This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
i;m getting this error below , it;s j2ee application , getting some data form DB then display it in excel sheet .
my environment :
1- No reporting framework used
2- using apache POI
3- IDE myeclipse
4- tomcat server
5- Windows xp
Check how much memory is allocated to tomcat. Tune it with the -Xmx and -Xms switch
If you are loading too many classes, you may be required to increase the perm gen space of the heap
Use a profiler to find out where all that memory is being eaten up.
If i remember correctly POI has a problem loading more than N number of records into an excel sheet. I cant confirm though. I heard something similar from a colleague a while back, but its so far back that I cannot remember
William Brogden wrote:It may not be a coding flaw, your problem is just too big for the default Java memory allocation of 64mb.
You should either:
1. use startup.bat with the memory setting JAVA_OPTS line I showed before
- or -
2. figure out how to assign more memory when starting using tomcat6.exe
For 2 - I cant help you there, I always use startup.bat for maximum control of the environment.
int the tomcat directory i found tomcat6w.exe in the java tab i can set initial memory pool and maximum memory pool i set them to 256 and 512 , and restarted the server and run my application but still the java heap error occurs !!!
Author and all-around good cowpoke
Joined: Mar 22, 2000
Did the number 81920 change with more memory allocated?
If this was my problem I would try inserting logging statements at various points using the Runtime freeMemory() call to find out how much memory is left at various points.
How are you doing your data processing ? How do you open your result set ? Any special parameters ?
If you're basically just dumping data from the DB to Excel, it's your treatment that loads too much data in memory, even if you increase the Tomcat memory to the max available, it might still crash.
Your code looks rather like you're constructing an object in memory that will hold data for all your available rows. Can't you process one line at a time and write to excel after each processed line ? ( but I might have gotten wrong your code excerpt, please add details if this is the case )