Hi Guys,
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 data you get from DB and print the size of that data. If that data contains so many size and you try to store that data into some variable then in general it gives erro like this.
I often see mis-behaving recursive calls triggering this type of error. If you've got any recursive calls in your code, you might want to monitor them.
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:1. How much memory are you giving Tomcat?
2. Does this happen on the first request or does it take multiple requests to cause it?
Bill
Actually , how i know the amount of memory given to the tomcat server ?
i tried java-Xms265m -Xmx512m but this response occured is this ok ?
How can i display the current values for Xms and Xmx ?
Any recommendations Guys ?
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12265
1
posted
0
IF - you are starting Tomcat via the startup.bat /catalina.bat method
THEN - You can control the amount of memory Tomcat starts with by adding a JAVA_OPTS environment setting. For example to give Tomcat and initial 128mb with maximum 256mb:
Insert in Catalina.bat around line 43 after the block of REM statements
set JAVA_OPTS=-Xms128m -Xmx256m
Look further in catalina.bat to see where JAVA_OPTS is used.
William Brogden wrote:IF - you are starting Tomcat via the startup.bat /catalina.bat method
THEN - You can control the amount of memory Tomcat starts with by adding a JAVA_OPTS environment setting. For example to give Tomcat and initial 128mb with maximum 256mb:
Insert in Catalina.bat around line 43 after the block of REM statements
set JAVA_OPTS=-Xms128m -Xmx256m
Look further in catalina.bat to see where JAVA_OPTS is used.
Bill
What if i;m running tomcat through tomcat6.exe ?
Mateus Lucio
Ranch Hand
Joined: Jul 27, 2006
Posts: 57
posted
0
Hi there!
I suggest you track down the problem's source ... what is using so much memory that is crashing the jvm?
if you just give it more memory, without knowing what's causing the problem, sooner or later you'll get it again.
I suggest you track down the problem's source ... what is using so much memory that is crashing the jvm?
if you just give it more memory, without knowing what's causing the problem, sooner or later you'll get it again.
Guys ,
I found this exceptions occurs after retrieving 81920 record from the DB here is my code :
i reviewed my class all looks fine ,is there a way to maintain this part of code to prevent this exception ?
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12265
1
posted
0
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.
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.
Bill
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 !!!
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12265
1
posted
0
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.
Bill
Billy JK
Greenhorn
Joined: Oct 02, 2002
Posts: 20
posted
0
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 )