Advertisement

02.26.2004 at 08:36AM PST, ID: 20899033
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Tomcat 5.0.18 Memory Leak
Tags: tomcat, memory
I'm having memory leakage problems on Tomcat 5.0.18.  Here is some insight to my configuration:

IIS6 on Windows Server 2003.  Tomcat is communicating with IIS6 using the Tomcat ISAPI redirector.  We currently have about 50 virtual hosts on Tomcat.  Each one of these hosts use JDBC to connect to our MySQL server which is on the same server.

Our server has two Intel Xeon CPUs running at  2.80 MHz each with 1GB of RAM.

We are running Tomcat as a service with the following options:
-Xrs -Xms64m -Xmx256m

Our websites (all 50 of them) get around 70,000 hits total.  Very soon, there will be an additional 50 more same-type websites to this server.  All our websites are duplicates of the same site with different designs.  Basically, they are running the same application through a second context path (the other context path is the root of our websites).

Our main problem is that whenever we run tomcat, our java.exe keeps growing (I check the mem usage on task manager).  It usually starts with something around 100MB.  Then all of a sudden, it jumps to 200 something and then keeps growing very very slowly.  In about 10 - 12 hours, it becomes something around 400 MB.  Even so, all of our websites function without any problems, however it's not OK to have a 400MB java.exe running, because it slows down our server and of course, our websites due to the fact that it starts using the page file.

Apart from java.exe, Tomcat has a heap size of 64 to 256 MB (-Xms64m -Xmx256m).  This doesn't show on the task manager.  I think this heap is used for our applications.  When I monitor it through the tomcat manager status page, everything seems OK.  My total memory starts with 64MB, it grows upto 256 MB as needed.  Garbage collection seems to be working fine freeing memory in minor and major cycles accordingly.  Sometimes the major cycle takes a little long pausing our servers for 30 to 60 seconds, but I'm guessing that this is normal.

I'm planning to change -Xms64m to -Xms128m on our next restart.  64MB is simply too small.

I just noticed today that Tomcat 5.0.19 is released.  I will try to upgrade to that at night time when there is not much traffic on our servers.  However, I'm afraid that the upgrade won't solve my problem.  On the release notes of 5.0.19, I haven't noticed any bug fixes for memory leakage.

How can I stabilize the size of java.exe.  We don't want to restart Tomcat server every 12 hours.

Thanks,

Asim
Start your free trial to view this solution
Question Stats
Zone: Software
Question Asked By: asimalp
Solution Provided By: vzilka
Participating Experts: 1
Solution Grade: A
Views: 204
Translate:
Loading Advertisement...
02.26.2004 at 12:42PM PST, ID: 10463641

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.26.2004 at 12:57PM PST, ID: 10463789

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.26.2004 at 06:02PM PST, ID: 10466071

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.26.2004 at 11:45PM PST, ID: 10467322

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.27.2004 at 12:13AM PST, ID: 10467401

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.27.2004 at 02:40AM PST, ID: 10468034

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.27.2004 at 07:36AM PST, ID: 10470043

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.28.2004 at 01:14AM PST, ID: 10475223

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.29.2004 at 06:56PM PST, ID: 10483549

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.01.2004 at 12:26AM PST, ID: 10484620

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.01.2004 at 11:08AM PST, ID: 10488884

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
02.26.2004 at 12:42PM PST, ID: 10463641

Rank: Master

Did you check your application with a profiling tool?
Which JDK do you have?
 
02.26.2004 at 12:57PM PST, ID: 10463789
I'm using Sun's 1.4.2_03-b02 JDK.  I tried using JProfiler.  However, I could not set the -Xms and -Xmx variables.  (I used to set them from the Tomcat Configuration utility.  I start Tomcat as a service, not by using startup.bat)  The server ended up starting with the 64MB of RAM which wasn't enough.  I had to turn off JProfiler immediately.  I could try using some other profiler that you would recommend.

Maybe my problem is related to a fix in 5.0.19.  Here is the change log for 5.0.19 (remember, I'm using 5.0.18): http://jakarta.apache.org/tomcat/tomcat-5.0-doc/changelog.html.  Please take a look at the 3rd item on Cayote.  It reads "Add request unregistration, to avoid the memory leak which was  affecting HTTP (billbarker)"

When I tried installing 5.0.19 on our testing server, I'm getting an internal NullPointerException whenever I try to use crosscontext c:imports.
 
02.26.2004 at 06:02PM PST, ID: 10466071

Rank: Master

I read the 5.0.19, but I am not sure this is relevant.
Can't you try, just for profiling sake, run Tomcat from the batch file? JProfiler is a good product.

Can you provide more info on the null pointer exceptions?
Also, why use a beta version JDK?
 
02.26.2004 at 11:45PM PST, ID: 10467322
I doubt that I'm using the beta version of the JDK.  This is the latest downloadable version from java.sun.com.  Here is where I have downloaded the file from: http://java.sun.com/j2se/1.4.2/download.html (first SDK download in the Download J2SE v 1.4.2_03 section.  In the release notes (http://java.sun.com/j2se/1.4.2/ReleaseNotes.html) it reads "The official version number for update release 1.4.2_03 is 1.4.2_03-b02".  If you feel that this is the beta version, I could try installing some other version, not a problem at all.

I have started Tomcat using JProfiler with the -Xms128m -Xmx256m options.  I saved a couple of snapshots.  Should I send them to your email address provided in your user profile (liran@2...4.com)?  Is there anything more spesific you need?
 
02.27.2004 at 12:13AM PST, ID: 10467401
Here is what I observed after playing around JProfiler:

When I load a DB intensive page with lots of data, my objects do use reasonable amounts of memory.  However, after running garbage collection manually, everything gets recycled 100%.  So I assume that there is no memory leakage on my application.  The weird thing is that, even though JProfiler shows that all the memory is recycled, java.exe's size stays the same.
 
02.27.2004 at 02:40AM PST, ID: 10468034

Rank: Master

It is not so weird, since the jvm captures allot more memory than the memory you specify in the heap.
If after some time (lets say an hour) you still see that everything is recycled, than the problem is probably with Tomcat.
If this is the case, we should try to narrow it done to what specific action causes the memory leak.
Can you give me more info on the structure of your application and the process that is done when you notice the memory leaks?

Also - try tuning your JVM so that there will be less major GCs, especially if it blocks your application for such a long time (30-60s)
 
02.27.2004 at 07:36AM PST, ID: 10470043
I have tuned my JVM so that the GCs don't take so long.  In fact, I noticed that it was a redundant info because it was taken care of before I posted my question.  Prior to posting my question, I have allocated 512MB max memory to Tomcat which was way too much.  Most of the memory was on the page file...

The structure of my application is actually very straight forward.  All it does is that it reads data from a MySQL database, and then represents the data in a nice format.

Last night, I think I found the reason as to why my java.exe's memory doubles very fast.  Here is what happens:

When I first start tomcat, my java.exe is about 65MB.  When I surf one of our websites, it doesn't really increase much.  However, we've got a rather unusual page on one of our website that needs to display approximately 20,000 rows of MySQL data.  When I click on that page, java.exe goes from 65 MB to ~120 MB in a matter of seconds.  Then, when I refresh the page, it goes to upto ~155 MB.  However, on the third refresh, it stays at ~155 MB, it stops increasing.  When I take a look at the data from JProfiler, I see that most of this data is stored as java.lang.String.  However, after GC, it gets recycled.

Last night, when I stopped testing at 4 AM, my java.exe was ~155MB.  Today, as of 10 AM, it is 246 MB (and we don't get much hits until 8 AM in the morning).  I'm guessing that my memory keeps increasing on every SQL query, however I don't notice it much simply because the size of the result set is usually very very small.  However the 20,000-row case gives me a hint.  What do you think?

Further more, JProfiler clearly shows that my data gets recycled.  You asked me what happens in an hour...  Tomcat status manager shows that it gets recycled.  In fact right now, my total Tomcat heap size is 210 MB and free memory is 150 MB.  About 15 minutes ago, the total heap size was the same, but the free memory was about 30 MB.  Somehow, this doesn't get reflected on java.exe.  I guess the task manager doesn't notice that the most of the heap is empty.

Does this mean that java.exe includes the total heap size of Tomcat?  I used to think that task manager didn't show the heap size in the processes view.  If so, maybe the task manager doesn't know what's really going on in the heap.  If this is the case java.exe is only getting larger depending on the total heap size.  When my total heap size reaches 256MB (-Xmx256m), my java.exe might get stabilized at around 350 MB.  As long as I can prove that it is stabilized (regardless of how big it gets), I would consider the problem solved.  That would mean that there is no memory leakage which is my main concern.
 
02.28.2004 at 01:14AM PST, ID: 10475223

Rank: Master

The windows task manager just shows the memory usage of the java.exe task. It includes everything the JVM allocates - the heap and some more internal data structures for itself.
THe JVM does not release memory the OS allocated to it - it handles its own memory and the assumption is that getting memory from the OS is time consuming, so it won't release it based on the GC behavior (this would dramatically decrease performance).

I don't understand now - if the java.exe memory on the task manager stabilize on 350 MB and does not increase all the time than you are OK - it is a normal behavior that does not point to memory leaks. if the java.exe size keeps increasing - then you have a memory leak.
 
02.29.2004 at 06:56PM PST, ID: 10483549
Thank you very much for the explanation.  Just to be on the same page and clear my doubts, I have one last question:

Since our max heap size is 256 MB, it is not actually technically possible for java.exe to grow indefinetely, because Tomcat would throw "Out of Memory" error once the heap is full.  So, as a conclusion: Unless I get an Out of Memory error on normal conditions (reasonable amount of requests), there is no memory leak.

Are we on the same page?  If so, I'm satisfied that everything is running fine (I made some optimizations to our source code so that our application doesn't require more than 256 MB of memory.  It's been working fine since friday).

Thank you,

Asim
 
03.01.2004 at 12:26AM PST, ID: 10484620

Rank: Master

YOu are correct.
Accepted Solution
 
03.01.2004 at 11:08AM PST, ID: 10488884
Thank you very much for your patience and help.  I learned a lot about the heap size and the JVM memory relationship.  Everything seems to be working fine on our servers.
 
 
20080236-EE-VQP-29