RE: virtual host memory usage
You are correct. My suggestion was that you in one case had a file in the common/lib directory, while in another you had it in the WEB-INF/lib directory. George Sexton MH Software, Inc. http://www.mhsoftware.com/ Voice: 303 438 9585 -Original Message- From: Oleg [mailto:[EMAIL PROTECTED] Sent: Sunday, August 14, 2005 7:39 PM To: Tomcat Users List Subject: Re: virtual host memory usage I am sorry, what do you mean by host class loader? From what I understand there are 3 ways to load classes, /common/lib (used by tomcat), shared/lib (used by all applications), webapp/web-inf/lib used by this one application. Thank you Oleg On 8/13/05, George Sexton [EMAIL PROTECTED] wrote: The obvious first guess is that you have a class that is in the host classloader, and not the common classloader, and that class is consuming large amounts of memory. George Sexton MH Software, Inc. http://www.mhsoftware.com/ Voice: 303 438 9585 -Original Message- From: Oleg [mailto:[EMAIL PROTECTED] Sent: Saturday, August 13, 2005 11:20 AM To: Tomcat Users List Subject: virtual host memory usage Why running 100 virutal hosts in Tomcat takes up much more memory than running a 100 identical applications under one host? Is there a way to configure Tomcat to run both the same? Thank you Oleg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: virtual host memory usage
Oh I see, well actually what I do, since all users with virtual hosts running identical applications, I place all application related libraries in shared/lib and WEB-INF/lib has only one jar which is application itself and its not in shared or common, common/lib only has Tomcat5 libraries plus database driver jar since I am using JNDI. Does that sound about right? Thanks Oleg On 8/15/05, George Sexton [EMAIL PROTECTED] wrote: You are correct. My suggestion was that you in one case had a file in the common/lib directory, while in another you had it in the WEB-INF/lib directory. George Sexton MH Software, Inc. http://www.mhsoftware.com/ Voice: 303 438 9585 -Original Message- From: Oleg [mailto:[EMAIL PROTECTED] Sent: Sunday, August 14, 2005 7:39 PM To: Tomcat Users List Subject: Re: virtual host memory usage I am sorry, what do you mean by host class loader? From what I understand there are 3 ways to load classes, /common/lib (used by tomcat), shared/lib (used by all applications), webapp/web-inf/lib used by this one application. Thank you Oleg On 8/13/05, George Sexton [EMAIL PROTECTED] wrote: The obvious first guess is that you have a class that is in the host classloader, and not the common classloader, and that class is consuming large amounts of memory. George Sexton MH Software, Inc. http://www.mhsoftware.com/ Voice: 303 438 9585 -Original Message- From: Oleg [mailto:[EMAIL PROTECTED] Sent: Saturday, August 13, 2005 11:20 AM To: Tomcat Users List Subject: virtual host memory usage Why running 100 virutal hosts in Tomcat takes up much more memory than running a 100 identical applications under one host? Is there a way to configure Tomcat to run both the same? Thank you Oleg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: virtual host memory usage
I am sorry, what do you mean by host class loader? From what I understand there are 3 ways to load classes, /common/lib (used by tomcat), shared/lib (used by all applications), webapp/web-inf/lib used by this one application. Thank you Oleg On 8/13/05, George Sexton [EMAIL PROTECTED] wrote: The obvious first guess is that you have a class that is in the host classloader, and not the common classloader, and that class is consuming large amounts of memory. George Sexton MH Software, Inc. http://www.mhsoftware.com/ Voice: 303 438 9585 -Original Message- From: Oleg [mailto:[EMAIL PROTECTED] Sent: Saturday, August 13, 2005 11:20 AM To: Tomcat Users List Subject: virtual host memory usage Why running 100 virutal hosts in Tomcat takes up much more memory than running a 100 identical applications under one host? Is there a way to configure Tomcat to run both the same? Thank you Oleg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
virtual host memory usage
Why running 100 virutal hosts in Tomcat takes up much more memory than running a 100 identical applications under one host? Is there a way to configure Tomcat to run both the same? Thank you Oleg
Re: virtual host memory usage
To my knowledge (sometimes limited but open to expansion) the answer is no. I base this on the understanding that each host loaded by Tomcat takes up memory space. Then add the application to that. Doug - Original Message - From: Oleg [EMAIL PROTECTED] To: Tomcat Users List tomcat-user@jakarta.apache.org Sent: Saturday, August 13, 2005 1:19 PM Subject: virtual host memory usage Why running 100 virutal hosts in Tomcat takes up much more memory than running a 100 identical applications under one host? Is there a way to configure Tomcat to run both the same? Thank you Oleg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: virtual host memory usage
The obvious first guess is that you have a class that is in the host classloader, and not the common classloader, and that class is consuming large amounts of memory. George Sexton MH Software, Inc. http://www.mhsoftware.com/ Voice: 303 438 9585 -Original Message- From: Oleg [mailto:[EMAIL PROTECTED] Sent: Saturday, August 13, 2005 11:20 AM To: Tomcat Users List Subject: virtual host memory usage Why running 100 virutal hosts in Tomcat takes up much more memory than running a 100 identical applications under one host? Is there a way to configure Tomcat to run both the same? Thank you Oleg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
memory usage
Hi everyone, I'm not quite sure where to post this problem - the tomcat, tapestry or cayenne mailing list - but here goes... I have an app built on the mentioned technologies. I click arround and monitor the memory usage (using the Win task manager - good enough for rough measurements). The memory usage seems to grow up to a 100 MB (Cayenne accesses a single table of about fifty attributes and a 1000 rows - don't ask) and sometimes - I can't reproduce the problem now - the app brakes when trying to open a new page. The exception says something about not having enough memory. Ring any bells, anyone? Thanks for your effort, Tomislav - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: memory usage
On Fri, Mar 18, 2005 at 07:43:41PM +0100, t.n.a. wrote: : rough measurements). The memory usage seems to grow up to a 100 MB : (Cayenne accesses a single table of about fifty attributes and a 1000 : rows - don't ask) and sometimes - I can't reproduce the problem now - : the app brakes when trying to open a new page. The exception says : something about not having enough memory. : Ring any bells, anyone? Yes -- if a Java app is out of memory, 1/ invest in a profiler to see whether there's a resource leak 2/ increase the heap such that the JVM has more space in which to create objects btw, please post a *new* message when writing to the list. Replying to an old (unrelated) message confuses thread-aware mailers, which makes your question harder to find (and thus answer). -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Memory Usage from Mbean
Hi. I'm trying to build a Servlet to retrieve some memory information about tomcat. I'm using Tomcat 5.5.7. Which bean contains the jvm memory data? Thanx ___ Roberto Cosenza http://robcos.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tomcat Connections And Memory Usage
Apache Version: 2.0.47 Tomcat Version: 4.1.29 Connector: mod_jk Server: SunOS 5.9 Generic_112233-07 sun4u sparc SUNW,Ultra-250 Does Tomcat have a configurable maximum number of simultaneous connections (ala Apache's MaxClients property)? If so, how/where is this value configured? If not, is the connection limit determined by the front-end web server? or by machine resource limits? How do we determine how much memory Tomcat is using per connection? -- David Rickard Software Engineer TechBooks/GTS Your Single Source Solution! Los Angeles CA * York, PA * Boston,MA * New Delhi, India Visit us on the World Wide Web http://www.techbooks.comhttp://www.techbooks.com [EMAIL PROTECTED] 5650 Jillson St., Los Angeles, CA 90040 (323) 888-8889 x331 (323) 888-1849 (Fax)
Re: Tomcat Connections And Memory Usage
To answer the first part of your question, you can configure the number of request threads on a per-connector basis: http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/coyote.html http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/jk2.html [EMAIL PROTECTED] 12/3/2004 1:55:39 PM Apache Version: 2.0.47 Tomcat Version: 4.1.29 Connector: mod_jk Server: SunOS 5.9 Generic_112233-07 sun4u sparc SUNW,Ultra-250 Does Tomcat have a configurable maximum number of simultaneous connections (ala Apache's MaxClients property)? If so, how/where is this value configured? If not, is the connection limit determined by the front-end web server? or by machine resource limits? How do we determine how much memory Tomcat is using per connection? -- David Rickard Software Engineer TechBooks/GTS Your Single Source Solution! Los Angeles CA * York, PA * Boston,MA * New Delhi, India Visit us on the World Wide Web http://www.techbooks.comhttp://www.techbooks.com [EMAIL PROTECTED] 5650 Jillson St., Los Angeles, CA 90040 (323) 888-8889 x331 (323) 888-1849 (Fax)
RE: Tomcat Connections And Memory Usage
Hi, You configure the number of request processing threads Tomcat allows. Because the Servlet Specification mandates that one request be served by one Servlet Container thread, this effectively controls the maximum number of concurrent clients Tomcat can serve. See the Connector documentation reference page for details on these properties (maxProcessors/maxThreads, maxSpareThreads, etc.) Determining the amount of memory per connection is a difficult task, and I say difficult only because I like to think nothing is impossible. Tomcat certainly doesn't track this out of the box, you'd have to do some coding. Yoav Shapira http://www.yoavshapira.com -Original Message- From: David Rickard [mailto:[EMAIL PROTECTED] Sent: Friday, December 03, 2004 2:56 PM To: [EMAIL PROTECTED] Subject: Tomcat Connections And Memory Usage Apache Version: 2.0.47 Tomcat Version: 4.1.29 Connector: mod_jk Server: SunOS 5.9 Generic_112233-07 sun4u sparc SUNW,Ultra-250 Does Tomcat have a configurable maximum number of simultaneous connections (ala Apache's MaxClients property)? If so, how/where is this value configured? If not, is the connection limit determined by the front-end web server? or by machine resource limits? How do we determine how much memory Tomcat is using per connection? -- David Rickard Software Engineer TechBooks/GTS Your Single Source Solution! Los Angeles CA * York, PA * Boston,MA * New Delhi, India Visit us on the World Wide Web http://www.techbooks.comhttp://www.techbooks.com [EMAIL PROTECTED] 5650 Jillson St., Los Angeles, CA 90040 (323) 888-8889 x331 (323) 888-1849 (Fax) This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Memory Usage - Tomcat 5.0.25
Nandish Rudra wrote: Hello Everyone, I am writing about this error from yesterday. I used JProfiler to monitor my memory usage. And am now sure that each and every static object is trashed when the application is undeployed and the profiler shows that memory is free and all instance of the objects are GC'd. This works on a Windows 2000 setup of Tomcat 5.0.25 with Java 2 SDK version 1.4.2_04 and Ant 1.6.1, but fails miserably on GNU Linux 2.4.20-8 setup. this happens with both tomcat 5.0.25 and 5.0.27 Any ideas why something like this could be happening. Nandish Rudra ECI Conference call Service LLC. -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED] Sent: Monday, August 09, 2004 1:35 PM To: Tomcat Users List Subject: RE: Memory Usage - Tomcat 5.0.25 Hi, I have a couple of ideas. One is that your webapp maintain static or shared references to objects that prevent them from being garbage collected, and therefore memory from returning to the heap. Another is that a webapp undeploy is not guaranteed to reclaim all memory used by the webapp anyways so to count on this behavior is not smart. It is expected that every time you reload your webapp the overall memory usage of the server will go up a bit, as not all objects are gone (for example, if you have a static reference than the old classloader and anything that references it strongly will remain in memory). Yoav Shapira Millennium Research Informatics -Original Message- From: Nandish Rudra [mailto:[EMAIL PROTECTED] Sent: Monday, August 09, 2004 1:17 PM To: Tomcat Users List (E-mail) Subject: Memory Usage - Tomcat 5.0.25 Hello, I am having some memory issues while deploing/undeploying web applications to Tomcat. I am using Tomcat 5.0.25 with Java 2 SDK version 1.4.2_04 and Ant 1.6.1 on GNU Linux 2.4.20-8. I use ant to compile my web application and Tomcat's catalina-ant.jar to deploy it automatically. Here is my problem. When I undeploy/remove an application, Tomcat does not reclaim the memory being used by the web application and when the application is re-deployed/re-installed a significant increase in memory is seen. This increase is obviously the memory usage by the new instance of the web application. Does anyone have any idea as to why this is happening? Try looking at jvmstat (http://developers.sun.com/dev/coolstuff/jvmstat/) My own tests with show that its the permanent space of objects that gets filled up and not reclaimed after each reload. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Memory Usage - Tomcat 5.0.25
Hi, LONG-snip / Does anyone have any idea as to why this is happening? Try looking at jvmstat (http://developers.sun.com/dev/coolstuff/jvmstat/) My own tests with show that its the permanent space of objects that gets filled up and not reclaimed after each reload. Yup, that's as expected. Yoav Shapira - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: FW: Memory Usage - Tomcat 5.0.25
Hi, Yes the objects are GC'd but memory stays. If you look through yesterday's posts you will see emails that helped me solve the issue on Windows machine, but the issue is still alive with RedHat 9.0. I am in the process probing the linux boex's mepry to see what the is going on. Nandish Rudra ECI Conference Call Services, LLC -Original Message- From: Joseph Shraibman [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 11, 2004 8:54 PM To: Tomcat Users List Subject: Re: FW: Memory Usage - Tomcat 5.0.25 Nandish Rudra wrote: Hello Everyone, I am writing about this error from yesterday. I used JProfiler to monitor my memory usage. And am now sure that each and every static object is trashed when the application is undeployed and the profiler shows that memory is free and all instance of the objects are GC'd. This works on a Windows 2000 setup of Tomcat 5.0.25 with Java 2 SDK version 1.4.2_04 and Ant 1.6.1, but fails miserably on RedHat 9 setup. this happens with both tomcat 5.0.25 and 5.0.27 I'm a bit confused. Are you saying that the objects are GC'd on redhat 9 but the jvm is still big, or are you saying that the objects were never GC'd? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: FW: Memory Usage - Tomcat 5.0.25
What memory are you looking at, what ps returns? What does Runtime.freeMemory() and Runtime.totalMemory() return? Nandish Rudra wrote: Hi, Yes the objects are GC'd but memory stays. If you look through yesterday's posts you will see emails that helped me solve the issue on Windows machine, but the issue is still alive with RedHat 9.0. I am in the process probing the linux boex's mepry to see what the is going on. Nandish Rudra ECI Conference Call Services, LLC -Original Message- From: Joseph Shraibman [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 11, 2004 8:54 PM To: Tomcat Users List Subject: Re: FW: Memory Usage - Tomcat 5.0.25 Nandish Rudra wrote: Hello Everyone, I am writing about this error from yesterday. I used JProfiler to monitor my memory usage. And am now sure that each and every static object is trashed when the application is undeployed and the profiler shows that memory is free and all instance of the objects are GC'd. This works on a Windows 2000 setup of Tomcat 5.0.25 with Java 2 SDK version 1.4.2_04 and Ant 1.6.1, but fails miserably on RedHat 9 setup. this happens with both tomcat 5.0.25 and 5.0.27 I'm a bit confused. Are you saying that the objects are GC'd on redhat 9 but the jvm is still big, or are you saying that the objects were never GC'd? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: FW: Memory Usage - Tomcat 5.0.25
Hello QM, Thanks for your reply, it really cleared some things. First, tomcat has two levels for memory - allocated vs. used. While allocated increases with every spike by some amout and stays there, the used memor fluctuates. If I set the memory bounds for JVM by the mechanism you have said than once the allocated reaches that level, tomcat will crash(out of memory exception). Now, since all of the allcotaed memory is not being used, is there a way to control the allocated memory, as in, make it fluctuate with used memory. Regards, Nandish Rudra ECI Conference Call Services, LLC -Original Message- From: QM [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 10, 2004 8:38 PM To: Tomcat Users List Subject: Re: FW: Memory Usage - Tomcat 5.0.25 On Tue, Aug 10, 2004 at 04:54:26PM -0400, Nandish Rudra wrote: : I am writing about this error from yesterday. I used JProfiler to monitor my : memory usage. And am now sure that each and every static object is trashed : when the application is undeployed and the profiler shows that memory is : free and all instance of the objects are GC'd. Something else to consider: the memory for the JVM process isn't just the heap. The process maintains some memory for itself, outside of the designated heap ranges set with -Xmx and -Xms, for housekeeping and such. (This is often news to even experienced J2EE developers.) That may very well be what you're seeing. -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: FW: Memory Usage - Tomcat 5.0.25
Hello guys, I have finally figured how to make JVM work the way I want it to. Setting some of the following options helps control the allocated memory size by huge amounts. I would strongly recommend using them. echo Setting JAVA_OPTS set JAVA_OPTS=-Xmn32M -Xmx128M -XX:MaxHeapFreeRatio=30 -XX:+UseParallelGC echo Using JAVA_OPTS: %JAVA_OPTS% Related link would be : http://java.sun.com/docs/hotspot/VMOptions.html Now the problem is these work on a Windows box when placed in catalina.bat but fail on a redHat 9 (Kernel 2.4.20-8)machine, in two ways - 1. When I place it in catalina.sh tomcat fails to start. 3. When I place startup.sh, tomcat starts but the windows behavior is not imitated. Any suggestion, Nandish Rudra ECI Conference Call Services, LLC -Original Message- From: Nandish Rudra [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 11, 2004 11:09 AM To: 'Tomcat Users List' Subject: RE: FW: Memory Usage - Tomcat 5.0.25 Hello QM, Thanks for your reply, it really cleared some things. First, tomcat has two levels for memory - allocated vs. used. While allocated increases with every spike by some amout and stays there, the used memor fluctuates. If I set the memory bounds for JVM by the mechanism you have said than once the allocated reaches that level, tomcat will crash(out of memory exception). Now, since all of the allcotaed memory is not being used, is there a way to control the allocated memory, as in, make it fluctuate with used memory. Regards, Nandish Rudra ECI Conference Call Services, LLC -Original Message- From: QM [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 10, 2004 8:38 PM To: Tomcat Users List Subject: Re: FW: Memory Usage - Tomcat 5.0.25 On Tue, Aug 10, 2004 at 04:54:26PM -0400, Nandish Rudra wrote: : I am writing about this error from yesterday. I used JProfiler to monitor my : memory usage. And am now sure that each and every static object is trashed : when the application is undeployed and the profiler shows that memory is : free and all instance of the objects are GC'd. Something else to consider: the memory for the JVM process isn't just the heap. The process maintains some memory for itself, outside of the designated heap ranges set with -Xmx and -Xms, for housekeeping and such. (This is often news to even experienced J2EE developers.) That may very well be what you're seeing. -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: FW: Memory Usage - Tomcat 5.0.25
Nandish Rudra wrote: Hello Everyone, I am writing about this error from yesterday. I used JProfiler to monitor my memory usage. And am now sure that each and every static object is trashed when the application is undeployed and the profiler shows that memory is free and all instance of the objects are GC'd. This works on a Windows 2000 setup of Tomcat 5.0.25 with Java 2 SDK version 1.4.2_04 and Ant 1.6.1, but fails miserably on RedHat 9 setup. this happens with both tomcat 5.0.25 and 5.0.27 I'm a bit confused. Are you saying that the objects are GC'd on redhat 9 but the jvm is still big, or are you saying that the objects were never GC'd? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Memory Usage - Tomcat 5.0.25
Hello Everyone, I am writing about this error from yesterday. I used JProfiler to monitor my memory usage. And am now sure that each and every static object is trashed when the application is undeployed and the profiler shows that memory is free and all instance of the objects are GC'd. This works on a Windows 2000 setup of Tomcat 5.0.25 with Java 2 SDK version 1.4.2_04 and Ant 1.6.1, but fails miserably on GNU Linux 2.4.20-8 setup. this happens with both tomcat 5.0.25 and 5.0.27 Any ideas why something like this could be happening. Nandish Rudra ECI Conference call Service LLC. -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED] Sent: Monday, August 09, 2004 1:35 PM To: Tomcat Users List Subject: RE: Memory Usage - Tomcat 5.0.25 Hi, I have a couple of ideas. One is that your webapp maintain static or shared references to objects that prevent them from being garbage collected, and therefore memory from returning to the heap. Another is that a webapp undeploy is not guaranteed to reclaim all memory used by the webapp anyways so to count on this behavior is not smart. It is expected that every time you reload your webapp the overall memory usage of the server will go up a bit, as not all objects are gone (for example, if you have a static reference than the old classloader and anything that references it strongly will remain in memory). Yoav Shapira Millennium Research Informatics -Original Message- From: Nandish Rudra [mailto:[EMAIL PROTECTED] Sent: Monday, August 09, 2004 1:17 PM To: Tomcat Users List (E-mail) Subject: Memory Usage - Tomcat 5.0.25 Hello, I am having some memory issues while deploing/undeploying web applications to Tomcat. I am using Tomcat 5.0.25 with Java 2 SDK version 1.4.2_04 and Ant 1.6.1 on GNU Linux 2.4.20-8. I use ant to compile my web application and Tomcat's catalina-ant.jar to deploy it automatically. Here is my problem. When I undeploy/remove an application, Tomcat does not reclaim the memory being used by the web application and when the application is re-deployed/re-installed a significant increase in memory is seen. This increase is obviously the memory usage by the new instance of the web application. Does anyone have any idea as to why this is happening? Regards, NR - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
FW: Memory Usage - Tomcat 5.0.25
Hello Everyone, I am writing about this error from yesterday. I used JProfiler to monitor my memory usage. And am now sure that each and every static object is trashed when the application is undeployed and the profiler shows that memory is free and all instance of the objects are GC'd. This works on a Windows 2000 setup of Tomcat 5.0.25 with Java 2 SDK version 1.4.2_04 and Ant 1.6.1, but fails miserably on RedHat 9 setup. this happens with both tomcat 5.0.25 and 5.0.27 Any ideas why something like this could be happening. Nandish Rudra ECI Conference call Service LLC. -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED] Sent: Monday, August 09, 2004 1:35 PM To: Tomcat Users List Subject: RE: Memory Usage - Tomcat 5.0.25 Hi, I have a couple of ideas. One is that your webapp maintain static or shared references to objects that prevent them from being garbage collected, and therefore memory from returning to the heap. Another is that a webapp undeploy is not guaranteed to reclaim all memory used by the webapp anyways so to count on this behavior is not smart. It is expected that every time you reload your webapp the overall memory usage of the server will go up a bit, as not all objects are gone (for example, if you have a static reference than the old classloader and anything that references it strongly will remain in memory). Yoav Shapira Millennium Research Informatics -Original Message- From: Nandish Rudra [mailto:[EMAIL PROTECTED] Sent: Monday, August 09, 2004 1:17 PM To: Tomcat Users List (E-mail) Subject: Memory Usage - Tomcat 5.0.25 Hello, I am having some memory issues while deploing/undeploying web applications to Tomcat. I am using Tomcat 5.0.25 with Java 2 SDK version 1.4.2_04 and Ant 1.6.1 on GNU Linux 2.4.20-8. I use ant to compile my web application and Tomcat's catalina-ant.jar to deploy it automatically. Here is my problem. When I undeploy/remove an application, Tomcat does not reclaim the memory being used by the web application and when the application is re-deployed/re-installed a significant increase in memory is seen. This increase is obviously the memory usage by the new instance of the web application. Does anyone have any idea as to why this is happening? Regards, NR - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: FW: Memory Usage - Tomcat 5.0.25
On Tue, Aug 10, 2004 at 04:54:26PM -0400, Nandish Rudra wrote: : I am writing about this error from yesterday. I used JProfiler to monitor my : memory usage. And am now sure that each and every static object is trashed : when the application is undeployed and the profiler shows that memory is : free and all instance of the objects are GC'd. Something else to consider: the memory for the JVM process isn't just the heap. The process maintains some memory for itself, outside of the designated heap ranges set with -Xmx and -Xms, for housekeeping and such. (This is often news to even experienced J2EE developers.) That may very well be what you're seeing. -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Memory Usage - Tomcat 5.0.25
Hello, I am having some memory issues while deploing/undeploying web applications to Tomcat. I am using Tomcat 5.0.25 with Java 2 SDK version 1.4.2_04 and Ant 1.6.1 on GNU Linux 2.4.20-8. I use ant to compile my web application and Tomcat's catalina-ant.jar to deploy it automatically. Here is my problem. When I undeploy/remove an application, Tomcat does not reclaim the memory being used by the web application and when the application is re-deployed/re-installed a significant increase in memory is seen. This increase is obviously the memory usage by the new instance of the web application. Another important detail to note is that, this behaviour is not seen, in a same setup, on a Windows 2000 machine. Does anyone have any idea as to why this is happening? Regards, NR - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Memory Usage - Tomcat 5.0.25
Hello, I am having some memory issues while deploing/undeploying web applications to Tomcat. I am using Tomcat 5.0.25 with Java 2 SDK version 1.4.2_04 and Ant 1.6.1 on GNU Linux 2.4.20-8. I use ant to compile my web application and Tomcat's catalina-ant.jar to deploy it automatically. Here is my problem. When I undeploy/remove an application, Tomcat does not reclaim the memory being used by the web application and when the application is re-deployed/re-installed a significant increase in memory is seen. This increase is obviously the memory usage by the new instance of the web application. Does anyone have any idea as to why this is happening? Regards, NR - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Memory Usage - Tomcat 5.0.25
It took the message a while to showup on the list so resent it with some modification. please disregard the first message. The problem does happen on Windows. I was looking at the wrong process. NR - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Memory Usage - Tomcat 5.0.25
Hi, I have a couple of ideas. One is that your webapp maintain static or shared references to objects that prevent them from being garbage collected, and therefore memory from returning to the heap. Another is that a webapp undeploy is not guaranteed to reclaim all memory used by the webapp anyways so to count on this behavior is not smart. It is expected that every time you reload your webapp the overall memory usage of the server will go up a bit, as not all objects are gone (for example, if you have a static reference than the old classloader and anything that references it strongly will remain in memory). Yoav Shapira Millennium Research Informatics -Original Message- From: Nandish Rudra [mailto:[EMAIL PROTECTED] Sent: Monday, August 09, 2004 1:17 PM To: Tomcat Users List (E-mail) Subject: Memory Usage - Tomcat 5.0.25 Hello, I am having some memory issues while deploing/undeploying web applications to Tomcat. I am using Tomcat 5.0.25 with Java 2 SDK version 1.4.2_04 and Ant 1.6.1 on GNU Linux 2.4.20-8. I use ant to compile my web application and Tomcat's catalina-ant.jar to deploy it automatically. Here is my problem. When I undeploy/remove an application, Tomcat does not reclaim the memory being used by the web application and when the application is re-deployed/re-installed a significant increase in memory is seen. This increase is obviously the memory usage by the new instance of the web application. Does anyone have any idea as to why this is happening? Regards, NR - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Memory Usage - Tomcat 5.0.25
Hello Yaov, You are correct I do have a few static varibles that point to running threads and some other objects. When the application is shutdown I ensure that each thread is destroyed and all static varibales are set to null, including thread identifiers, this should let my call to GC clear the memory. You are also right in saying that i should not depend on undeploy to reclaim all memory that the webapp was using, and I don't. Like I mentioned I do make sure all static variables get set to null before the application shuts down. It would be understandable if not all memory utilized by the webapp is reclaimed, but in my case absolutely no memory is being reclaimed. For example, say, i start tomcat and it starts with 30M initial memory usage without the application. Now when i deploy the application the size jumps by 8M to 38M. As the app is undeploy and re-deploy the memory usage jumps from 38M to 46-47M. Now this, if I am not wrong, is not how things should be. I would appreciate anymore suggestion that you or anyone may have. Regards, Nandish -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED] Sent: Monday, August 09, 2004 1:35 PM To: Tomcat Users List Subject: RE: Memory Usage - Tomcat 5.0.25 Hi, I have a couple of ideas. One is that your webapp maintain static or shared references to objects that prevent them from being garbage collected, and therefore memory from returning to the heap. Another is that a webapp undeploy is not guaranteed to reclaim all memory used by the webapp anyways so to count on this behavior is not smart. It is expected that every time you reload your webapp the overall memory usage of the server will go up a bit, as not all objects are gone (for example, if you have a static reference than the old classloader and anything that references it strongly will remain in memory). Yoav Shapira Millennium Research Informatics -Original Message- From: Nandish Rudra [mailto:[EMAIL PROTECTED] Sent: Monday, August 09, 2004 1:17 PM To: Tomcat Users List (E-mail) Subject: Memory Usage - Tomcat 5.0.25 Hello, I am having some memory issues while deploing/undeploying web applications to Tomcat. I am using Tomcat 5.0.25 with Java 2 SDK version 1.4.2_04 and Ant 1.6.1 on GNU Linux 2.4.20-8. I use ant to compile my web application and Tomcat's catalina-ant.jar to deploy it automatically. Here is my problem. When I undeploy/remove an application, Tomcat does not reclaim the memory being used by the web application and when the application is re-deployed/re-installed a significant increase in memory is seen. This increase is obviously the memory usage by the new instance of the web application. Does anyone have any idea as to why this is happening? Regards, NR - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to conserve memory usage?
I have a web application which I want to deploy several times on one server, so that every customer has his own instance. How should I do this so that the memory footprint per deployment is minimized? A colleague suggested creating one .war file and referencing this file in several webapps/application_01.xml, webapps/application_02.xml etc. files. He said this would be more efficient than creating several identical webapps/application_01, webapps/application_02 etc. directories. Is this true? Are there any better approaches? When using the same approach with Tomcat 5 I discovered that the .war file is still unpacked several times in the webapps directory, once per conf/Catalina/localhost/application_nn.xml file. Do I now lose the memory consumption advantage compared to Tomcat 4? Are there any better methods to run many instances of the same web application inside one Tomcat? Mit schönen Grüßen von Yahoo! Mail - http://mail.yahoo.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: JVM Memory Usage
Hi, please let me know how can i control the JVM memory usage in tomcat Same as other java programs, using the java command-line options. See for example JAVA_OPTS in $CATALINA_HOME/bin/catalina.sh, or search this list's archives. Yoav Shapira This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Memory Usage
Hi all We've setup Tomcat to use a max of 256Mb. I've been tracking memory usage using: Runtime r = Runtime.getRuntime(); System.out.println(M: +r.maxMemory()); System.out.println(T: +r.totalMemory()); System.out.println(A: +r.freeMemory()); System.runFinalization(); System.gc(); System.out.println(A: +r.freeMemory()); Current reading is: M: 335544320 T: 5120 A: 23138080 A: 23479384 What I've noticed is that the the 'T' value (Total Memory) slowly increases, but never goes back down. According to the Runtime javadoc, this is the total amount of memory in the JVM. Will this continue to increase? What happens when it hits the Maximum memory amount? Should I be concerned about this? tia bort - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Memory Usage
Hi, We've setup Tomcat to use a max of 256Mb. I've been tracking memory usage using: System.runFinalization(); System.gc(); Be aware that the above two lines are misleading, as they are suggestions and not guaranteed to actually do anything. What I've noticed is that the the 'T' value (Total Memory) slowly increases, but never goes back down. According to the Runtime javadoc, this is the total amount of memory in the JVM. Will this continue to increase? What happens when it hits the Maximum memory amount? Should I be concerned about this? It will continue to increase as needed until and unless it hits a specified boundary, e.g. the amount you specify in -Xmx plus system memory overhead (e.g. the stack and symbol table). If all available memory is allocated and more memory is requested, you will get a java.lang.OutOfMemoryError. Should you be concerned about this? Of course ;) You should always know how much memory your system requires to handle its expected loads, and you should configure your system according to this knowledge. For example, why did you pick 256MB maximum? Yoav Shapira This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Memory Usage
If System.runFinalization() and System.gc() are misleading... what should I use instead, to force to garbage collection? So, the amount of memory the JVM uses, will always increase? How do I get it to decrease? 256 was an arbitrary choice. Is there some formula I should be using (based on projected traffic)? bort Shapira, Yoav [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, We've setup Tomcat to use a max of 256Mb. I've been tracking memory usage using: System.runFinalization(); System.gc(); Be aware that the above two lines are misleading, as they are suggestions and not guaranteed to actually do anything. What I've noticed is that the the 'T' value (Total Memory) slowly increases, but never goes back down. According to the Runtime javadoc, this is the total amount of memory in the JVM. Will this continue to increase? What happens when it hits the Maximum memory amount? Should I be concerned about this? It will continue to increase as needed until and unless it hits a specified boundary, e.g. the amount you specify in -Xmx plus system memory overhead (e.g. the stack and symbol table). If all available memory is allocated and more memory is requested, you will get a java.lang.OutOfMemoryError. Should you be concerned about this? Of course ;) You should always know how much memory your system requires to handle its expected loads, and you should configure your system according to this knowledge. For example, why did you pick 256MB maximum? Yoav Shapira This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Memory Usage
Hi, Now you're starting to ask the right questions. If System.runFinalization() and System.gc() are misleading... what should I use instead, to force to garbage collection? You can't force garbage collection, and it is terrible design to rely on particular garbage collection timing. Instead, know that the JVM is pretty damn good at doing GC, and take throughout your code to not keep any unneeded references and limit the scope of references as much as possible. So, the amount of memory the JVM uses, will always increase? How do I get it to decrease? The amount of memory the JVM uses will monotonically increase up to the heap limit you set for it via -Xmx plus overhead space e.g. the stack and symbol tables. You can't get it to decrease. You will find this page helpful, I believe: http://jakarta.apache.org/tomcat/faq/memory.html 256 was an arbitrary choice. Is there some formula I should be using (based on projected traffic)? There's no formula in mathematical terms, but there IS a standard procedure to follow: 1. Establish the maximum expected number of concurrent users your system should handle, and the average page response time when handling this number of users. 2. Write a stress test plan using your favorite tool, e.g. JMeter, to simulate the load determined in #1. 3. Run the tool against your system without any tuning options. If you run out of memory, increase available memory (-Xmx) and repeat. If you run out of memory but you're fairly sure your system has enough, consider running with a profiler to see if there are leaks or other unnecessary memory usage patterns. Yoav Shapira This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Memory Usage
bort wrote: If System.runFinalization() and System.gc() are misleading... what should I use instead, to force to garbage collection? So, the amount of memory the JVM uses, will always increase? How do I get it to decrease? You can't get it to decrease, but if you have the memory large enough so that it doesn't have to request any more from the system, it won't continue to grow. If it is growing without bounds you probably have a memory leak. JDK1.5.0beta seems to have an improved garbage collection tuning built in, and that may be of some help, but if you have a leak then all you can do it find it. You may want to learn more about garbage collection. You could use these references: http://java.sun.com/docs/hotspot/gc1.4.2/faq.html http://www-106.ibm.com/developerworks/java/library/j-jtp11253/ http://java.sun.com/docs/hotspot/gc1.4.2/ 256 was an arbitrary choice. Is there some formula I should be using (based on projected traffic)? The links above, esp the third one, should help you to determine what is a good size. -- Love is mutual self-giving that ends in self-recovery. Fulton Sheen James Black[EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Memory Usage
Hi, JDK1.5.0beta seems to have an improved garbage collection tuning built Care to elaborate or provide a reference? Thanks, Yoav Shapira Millennium Research Informatics This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Memory Usage
Shapira, Yoav wrote: Hi, JDK1.5.0beta seems to have an improved garbage collection tuning built Care to elaborate or provide a reference? Thanks, http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html#vm_selftune Based on my own experience, doing various performance related tests with Tomcat 5, running under JDK1.5 I find it interesting to watch the size of the java application decrease, over time. I don't set anything for the heap except -mx512M, so I can see how it performs. When I run my unit tests inside of JProfiler I also can watch the total heap decrease, while the unit test is running. -- Love is mutual self-giving that ends in self-recovery. Fulton Sheen James Black[EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Memory Usage
Hi, Great, exactly what I wanted. Thanks, Yoav Shapira Millennium Research Informatics -Original Message- From: James Black [mailto:[EMAIL PROTECTED] Sent: Monday, March 15, 2004 2:21 PM To: Tomcat Users List Subject: Re: Memory Usage Shapira, Yoav wrote: Hi, JDK1.5.0beta seems to have an improved garbage collection tuning built Care to elaborate or provide a reference? Thanks, http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html#vm_selftune Based on my own experience, doing various performance related tests with Tomcat 5, running under JDK1.5 I find it interesting to watch the size of the java application decrease, over time. I don't set anything for the heap except -mx512M, so I can see how it performs. When I run my unit tests inside of JProfiler I also can watch the total heap decrease, while the unit test is running. -- Love is mutual self-giving that ends in self-recovery. Fulton Sheen James Black[EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Memory Usage
Thank you for the information! James Black [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] bort wrote: If System.runFinalization() and System.gc() are misleading... what should I use instead, to force to garbage collection? So, the amount of memory the JVM uses, will always increase? How do I get it to decrease? You can't get it to decrease, but if you have the memory large enough so that it doesn't have to request any more from the system, it won't continue to grow. If it is growing without bounds you probably have a memory leak. JDK1.5.0beta seems to have an improved garbage collection tuning built in, and that may be of some help, but if you have a leak then all you can do it find it. You may want to learn more about garbage collection. You could use these references: http://java.sun.com/docs/hotspot/gc1.4.2/faq.html http://www-106.ibm.com/developerworks/java/library/j-jtp11253/ http://java.sun.com/docs/hotspot/gc1.4.2/ 256 was an arbitrary choice. Is there some formula I should be using (based on projected traffic)? The links above, esp the third one, should help you to determine what is a good size. -- Love is mutual self-giving that ends in self-recovery. Fulton Sheen James Black[EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Memory Usage
Thanks for the information! Shapira, Yoav [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, Now you're starting to ask the right questions. If System.runFinalization() and System.gc() are misleading... what should I use instead, to force to garbage collection? You can't force garbage collection, and it is terrible design to rely on particular garbage collection timing. Instead, know that the JVM is pretty damn good at doing GC, and take throughout your code to not keep any unneeded references and limit the scope of references as much as possible. So, the amount of memory the JVM uses, will always increase? How do I get it to decrease? The amount of memory the JVM uses will monotonically increase up to the heap limit you set for it via -Xmx plus overhead space e.g. the stack and symbol tables. You can't get it to decrease. You will find this page helpful, I believe: http://jakarta.apache.org/tomcat/faq/memory.html 256 was an arbitrary choice. Is there some formula I should be using (based on projected traffic)? There's no formula in mathematical terms, but there IS a standard procedure to follow: 1. Establish the maximum expected number of concurrent users your system should handle, and the average page response time when handling this number of users. 2. Write a stress test plan using your favorite tool, e.g. JMeter, to simulate the load determined in #1. 3. Run the tool against your system without any tuning options. If you run out of memory, increase available memory (-Xmx) and repeat. If you run out of memory but you're fairly sure your system has enough, consider running with a profiler to see if there are leaks or other unnecessary memory usage patterns. Yoav Shapira This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
JVM Memory Usage
Hi all, I m new to tomcat please let me know how can i control the JVM memory usage in tomcat where to edit.. thanks akki - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Memory Usage/Common Lib
I was wondering how the memory usage of Tomcat should compare in the following two cases: I have application a, b, c. Each application uses x.jar, y.jar and z.jar. Scenario 1: Each application is deployed with the three jars under their respective WEB-INF/lib directories. Scenario 2: Nothing is placed in the respective WEB-INF/lib directories. Rather the three jars are placed in tomcat's common/lib directory. Would the memory usage of tomcat differ in the two cases? I'm assuming yes, since in the first case the classes need to be loaded three times more. In the second scenario, the classes from the jars would only be loaded up once. Therefore Scenario 1, in terms of memory allocated to the classloaded would be 3x more? I would like to get some feedback to confirm or deny this. Thanks. Important Notice to Recipients It is important that you do not use e-mail to request, authorize or effect the purchase or sale of any security or commodity, to send fund transfer instructions, or to effect any other transactions. Any such request, orders, or instructions that you send will not be accepted and will not be processed by Morgan Stanley.
RE: Memory Usage/Common Lib
Hi, Scenario 1: Each application is deployed with the three jars under their respective WEB-INF/lib directories. Scenario 2: Nothing is placed in the respective WEB-INF/lib directories. Rather the three jars are placed in tomcat's common/lib directory. Would the memory usage of tomcat differ in the two cases? I'm assuming yes, since in the first case the classes need to be loaded three times more. In the second scenario, the classes from the jars would only be loaded up once. Therefore Scenario 1, in terms of memory allocated to the classloaded would be 3x more? I would like to get some feedback to confirm or deny this. You're just about right. The memory allocated to the classloaders would be 3x more, as they must be separate and can have no overlap. However, in most real-life scenarios the independence and portability obtained by the WEB-INF/lib setup is far more valuable than the minor memory cost. I say minor even though it's 3x because it's 3x only for classes loaded, not the heap, which usually dwarfs the classloader memory by orders of magnitude. Yoav Shapira This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Memory Usage/Common Lib
Scenario 1 will use more memory than scenarion 2. The ratio depends on the internal architecture of the classes. (What kind of object they create, where they store it) If you just look at the core size that is needed to load the classes it roughly directly proportional to the number of webapp in scenario 2. But apart from that most classes need additional memory. (If the libray store all object in the session, the storage for this would change for both variants. If they store it in the classes it will make a difference) -Original Message- From: Lipov, Felix [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 10, 2004 2:55 PM To: Tomcat Users List Subject: Memory Usage/Common Lib I have application a, b, c. Each application uses x.jar, y.jar and z.jar. Scenario 1: Each application is deployed with the three jars under their respective WEB-INF/lib directories. Scenario 2: Nothing is placed in the respective WEB-INF/lib directories. Rather the three jars are placed in tomcat's common/lib directory. Would the memory usage of tomcat differ in the two cases? I'm assuming yes, since in the first case the classes need to be loaded three times more. In the second scenario, the classes from the jars would only be loaded up once. Therefore Scenario 1, in terms of memory allocated to the classloaded would be 3x more? I would like to get some feedback to confirm or deny this. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Memory usage raises when reloading a context
Every time that i reload a context (through the tomcat manager) the memory usage of the tomcat grows up a bit, and it doesn't go down again. Every time the context is reloaded the memory usage raises, until the jvm begins to throw OutOfMemory errors. Then i have to restart tomcat (of course). Although this isn't a big problem in a production environment, where the applications keep running without reloads, here in our development environment this is becoming a problem, since every time we make a modification we have to reload the application. I downloaded jvmstat to monitor the jvm, and i noticed that when an application is reloaded, the overall heap usage increases and the jvm gc moves a lot of objects to the heap's permanent area. I think that this might be the main problem. Because even if the old area increases, it will sometime get garbage collected and the memory freed. And this i could confirm using jvmstat. But the objects that are in the permanent area will never be garbage collected. Is this behaviour normal? Or maybe it's a problem with my specific configuration? I'm using tomcat 5.0.16, sun jvm 1.4.2_03-b02, redhat 9. Thanks! Vitor - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Memory usage raises when reloading a context
Howdy, It's normal: the classloader and associated objects can't get recycled and classes are stored in the permanent area. You can tweak the JVM's MaxPermSize if you'd like. As you noted, restarting your context all the time is not a typical production scenario. Yoav Shapira Millennium ChemInformatics -Original Message- From: Vitor Buitoni [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 04, 2004 6:58 AM To: Tomcat Users List Subject: Memory usage raises when reloading a context Every time that i reload a context (through the tomcat manager) the memory usage of the tomcat grows up a bit, and it doesn't go down again. Every time the context is reloaded the memory usage raises, until the jvm begins to throw OutOfMemory errors. Then i have to restart tomcat (of course). Although this isn't a big problem in a production environment, where the applications keep running without reloads, here in our development environment this is becoming a problem, since every time we make a modification we have to reload the application. I downloaded jvmstat to monitor the jvm, and i noticed that when an application is reloaded, the overall heap usage increases and the jvm gc moves a lot of objects to the heap's permanent area. I think that this might be the main problem. Because even if the old area increases, it will sometime get garbage collected and the memory freed. And this i could confirm using jvmstat. But the objects that are in the permanent area will never be garbage collected. Is this behaviour normal? Or maybe it's a problem with my specific configuration? I'm using tomcat 5.0.16, sun jvm 1.4.2_03-b02, redhat 9. Thanks! Vitor - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Average memory usage under 5.0.16 (jsvc)
Hello All, I've searched the archives for this and while I've found related information I haven't seen anything definitive. I'm using jsvc to run Tomcat 5.0.16 as a daemon and after startup when it's doing nothing it's using between 120 and 160 megs of physical memory. This seems high to me. Is this normal? Thanks, Andrew Davidoff - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
tomcat memory usage
Hello, I'm a beginner with java and I've setup tomcat (Apache Tomcat/5.0.16, jvm: 1.4.2_03-b02 Sun Microsystems Inc. on Gentoo Linux, kernel 2.4.20-gentoo-r8). I've created a context for my application and I used the manager to reload the context and now I've configured the context to be reloadable. My problem is that everytime the context is reloaded, top shows a memory usage increase with about 2Mb, until tomcat runs out of memory. What can I do ? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: tomcat memory usage
Andrei Ivanov wrote: I've created a context for my application and I used the manager to reload the context and now I've configured the context to be reloadable. First, start with using a profiler to ensure that your application isn't leaking memory. Look at http://issues.apache.org/bugzilla/ for anything on memory leaks wrt contexts. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: tomcat memory usage
I've searched bugzilla, but there doesn't seem to be any bug filled about something like this. About using a profiler... could you recommend one ? Thanks.. On Tue, 30 Dec 2003, James Black wrote: Andrei Ivanov wrote: I've created a context for my application and I used the manager to reload the context and now I've configured the context to be reloadable. First, start with using a profiler to ensure that your application isn't leaking memory. Look at http://issues.apache.org/bugzilla/ for anything on memory leaks wrt contexts. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: tomcat memory usage
About using a profiler... could you recommend one ? JProfiler JProbe __ Do you Yahoo!? Find out what made the Top Yahoo! Searches of 2003 http://search.yahoo.com/top2003 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: tomcat memory usage
Andrei Ivanov wrote: I've searched bugzilla, but there doesn't seem to be any bug filled about something like this. About using a profiler... could you recommend one ? JProfiler I like, mainly because of the cost, but also because it integrates in well with Netbeans. g Look at http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20758 and see if that is your problem. This may also help: http://www.junlu.com/msg/38658.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: tomcat memory usage
On Tue, 30 Dec 2003, James Black wrote: Andrei Ivanov wrote: I've searched bugzilla, but there doesn't seem to be any bug filled about something like this. About using a profiler... could you recommend one ? JProfiler I like, mainly because of the cost, but also because it integrates in well with Netbeans. g I have only console access (no xfree installed) on the remote server, and as I can see, jprofiler wants X to be installed. Anyway, I have no experience with profilers, so I don't know how much would that help. Look at http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20758 and see if that is your problem. This may be it, but I just reload the application context... does tomcat undeploy and then deploy the app when I reload it ? If there's more that I can do to discover the cause, using my limited experience, just tell me what... This may also help: http://www.junlu.com/msg/38658.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: tomcat memory usage
Howdy, Look at http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20758 and see if that is your problem. This may also help: http://www.junlu.com/msg/38658.html I clicked the above and surprisingly saw my own message ;) Anyways, note that bug 20758 is filed against tomcat 4.1.24. There's no such bug reported against tomcat 5, and work has definitely been done in this area. If you do submit a new one for tomcat 5, make sure to attach your simple test WAR file and the steps so we can reproduce this problem, or your bug will be marked as INVALID/WONTFIX. Yoav Shapira This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Memory Usage, Leakage and java.lang.OutofMemory
So let's say that I have a web app that is slowly but surely leaking. Eventually, I will get a java.lang.OutOfMemory error. With how Tomcat is internally architected, or with how the JVM operates, does this cause a problem for all other applications running under Tomcat? Is there now no more memory for *anything* running under Tomcat (and let's not forget Tomcat itself)? Or if I just 'reload' the problem webapp, will that 'release' all the memory that is currently being hogged by this app? --- Mike Curwen204-885-7733 Intermediate Programmer www.gb-im.com --- ___ __ __ / ___| | __ ) |_ _| | \/ | | | _ | _ \ _ | | | |\/| | | |_| | | |_) | |_| | | | | | | \| |/ |___| |_| |_| - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Memory Usage, Leakage and java.lang.OutofMemory
Howdy, Once you get an OutOfMemoryError, your JVM is in an unpredictable state and must be restarted. This is not specific to tomcat. Reloading the webapp will not do any good. Find the leak with a profiler and fix it ;) Yoav Shapira Millennium ChemInformatics -Original Message- From: Mike Curwen [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 17, 2003 11:17 AM To: [EMAIL PROTECTED] Subject: Memory Usage, Leakage and java.lang.OutofMemory So let's say that I have a web app that is slowly but surely leaking. Eventually, I will get a java.lang.OutOfMemory error. With how Tomcat is internally architected, or with how the JVM operates, does this cause a problem for all other applications running under Tomcat? Is there now no more memory for *anything* running under Tomcat (and let's not forget Tomcat itself)? Or if I just 'reload' the problem webapp, will that 'release' all the memory that is currently being hogged by this app? --- Mike Curwen204-885-7733 Intermediate Programmer www.gb-im.com --- ___ __ __ / ___| | __ ) |_ _| | \/ | | | _ | _ \ _ | | | |\/| | | |_| | | |_) | |_| | | | | | | \| |/ |___| |_| |_| - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Memory Usage, Leakage and java.lang.OutofMemory
Reloading the webapp may help. AFAIK it reloads all classes that are bound to the webapp classsloader and thus may free some memory that is hold by those classes. (Not that I think that it's a good idea to rely on that) -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 17, 2003 5:18 PM To: Tomcat Users List Subject: RE: Memory Usage, Leakage and java.lang.OutofMemory Once you get an OutOfMemoryError, your JVM is in an unpredictable state and must be restarted. This is not specific to tomcat. Reloading the webapp will not do any good. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Memory usage Tomcat 4.1.24
The recently installed Tomcat 4.1.24 on startup takes about 60M of memory. Is it my configuration. I have not noticed previous versions consuming so much. I have 6 or so applications in webapps - mainly struts - documentaion, examples etc. Using j2sdk1.4.0. Regards - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
high memory usage ....
Hi, I believe many other of you have encountered the high memory usage with tomcat? Is there a way to decrease the amount the java processes use? Furthermore, all the java processes are started under user root. Is there a way to start the java processes under another user? Any particular version of java and/or tomcat adviced to deal with these problems? I guess auditing the java applications which are written is also very nice to do and fixup some memory leaks if they're there? Bye, Mipam. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: high memory usage ....
I believe many other of you have encountered the high memory usage with tomcat? Is there a way to decrease the amount the java processes use? yes, take a close look at the Tomcat configuration reference (Connectors) Furthermore, all the java processes are started under user root. Is there a way to start the java processes under another user? This has been discussed approx. 2874438 times on this list ;-) Any particular version of java and/or tomcat adviced to deal with these problems? In general, memory comsumption is likely to decrease with newer JDKs. I also noted a noticeably startup speed improvement using 1.4.2 - but YMMV depending on deployment needs/restrictions. It might also be worth trying JDKs from different vendors. Regarding TC versions: always try to stay as up to date as possible - there are lot of continuos improvements regarding speed, stability, memory consumption and of cause fixed bugs. Additionally, TC5 has seen a lot of improvements regarding its inner workings resulting in better overall speed and less memory consumption. I guess auditing the java applications which are written is also very nice to do and fixup some memory leaks if they're there? There a lot of different tools (commercial and OSS) available, just do a search on google. Yann - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: high memory usage ....
on Wed, 20 Aug 2003 15:55:50 +0200 (MET DST) Mipam [EMAIL PROTECTED] wrote: Hi, [..] Furthermore, all the java processes are started under user root. Actually it's not up to java or tomcat. Is there a way to start the java processes under another user? su user -c path_to_executable or login as user and then run the code. Also it's possible but unprobable that your java is suided (no way!) Any particular version of java and/or tomcat adviced to deal with these problems? No, you rather should experiment with options liek (sun java) -Xm* and/or gc options I guess auditing the java applications which are written is also very nice to do and fixup some memory leaks if they're there? IMO it's hard to make a real memory leak in java. Regards, Rufio - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: high memory usage ....
Howdy, Yann Cébron [mailto:[EMAIL PROTECTED], said: Regarding TC versions: always try to stay as up to date as possible - there are lot of continuos improvements regarding speed, stability, memory consumption and of cause fixed bugs. Additionally, TC5 has seen a lot of improvements regarding its inner workings resulting in better overall speed and less memory consumption. Have you benchmarked tomcat 5.x vs. 4.1.x to come up with the above speed and memory consumption claims? I'd be very curious to see your benchmarks. Thanks, Yoav Shapira This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Memory usage
Is there a quick and easy way to figure out the actual memory use of everything related to the tomcat server? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Memory usage
Checkout jvmstat on http://developers.sun.com/techtopics/emergingtech/ -Original Message- From: Luc Foisy [mailto:[EMAIL PROTECTED] Sent: Thursday, July 10, 2003 3:19 PM To: Tomcat User List (E-mail) Subject: Memory usage Is there a quick and easy way to figure out the actual memory use of everything related to the tomcat server? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Memory usage
Hi, You could turn on verbose garbage collection and it will give you detailed info on the gc'ing. It will show you how much memory it is using... like a kinda before the collection and after the collection reading. This isn't something you want to run in production (for a long time at least). add -verbosegc to your JAVA_OPTS -e On Thu, 10 Jul 2003, Luc Foisy wrote: Is there a quick and easy way to figure out the actual memory use of everything related to the tomcat server? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Memory usage
I use 'ps' to figure it out (are you using linux?) I do something like: ps aux | grep tomcat i grep tomcat because that is the user my tomcat runs as... you could also use 'top' __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Memory Usage and Garbage Collection
Hi Steve, The real decision you need to make is how common are the common parts of your JSPs, and how much content is within the JSPs. If most of your JSPs are simply blocks of content surrounded by the same boiler plate JSP code, then perhaps it is worth while to make those JSPs a single JSP that then loads the different content at runtime based upon the request. But the real consideration is simply the amount of content that you're delivering within the JSPs. Consider this: If you have 500 JSP's that each have 20K of text (which is quite a bit of text if you think about it), then that's only 20MB of memory for the content. The calculation is 500 files x 20,000 characters x 2 for unicode (unicode characters, which Java uses, are 2 bytes). So, using brute force, back-of-napkin calculations, 512MB of memory would store 25000 of those documents. Also, if your document count is mostly static from day to day, i.e. you aren't adding large numbers of new documents each day, then you can easily pre-compute your overall memory burden simply for the documents, and scale appropriately. So, I doubt the JSPs alone are causing your memory problems, it's probably something else. Hope this was helpful, Regards, Will Hartung ([EMAIL PROTECTED]) - Original Message - From: Turoff, Steve [EMAIL PROTECTED] To: Will Hartung [EMAIL PROTECTED] Sent: Tuesday, January 14, 2003 10:07 AM Subject: RE: Memory Usage and Garbage Collection Will, I too am experiencing memory problems and I think your explanation below might apply to me. I'm using Tomcat 4.1 on RedHat Linux. Over the course of a few days, I notice, (using top) that the amount of physical memory used by the java processes continually increases until it exceeds the maximum that I've set (-Xmx512m) and then will generate an java.lang.OutOfMemoryError in $CATALINA_HOME/logs/localhost_log.-MM-DD.txt. I believe the problem is that my JSPs are dynamic, but I'm not sure exactly what differentiates a static JSP from a dynamic JSP. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Memory Usage and Garbage Collection
Will, I too am experiencing memory problems and I think your explanation below might apply to me. I'm using Tomcat 4.1 on RedHat Linux. Over the course of a few days, I notice, (using top) that the amount of physical memory used by the java processes continually increases until it hits the maximum that I've set (-Xmx512m) and then will generate an outOfMemory error. I believe the problem is that my JSPs are dynamic, but I'm not sure exactly what differentiates a static JSP from a dynamic JSP. I have several hundred JSPs - each one looks like: !-- BEGIN SAMPLE PAGE -- jsp:useBean id=thisPage class=PHN.PHNPage scope=session / jsp:setProperty name=thisPage property=section value=foo / %@ include file=/templates/header.jsp % I am body content. Some pages use the following java: a href=/a.pdfDocument a/a (PDF file - %= new File(/a.pdf).length()/1024 % %@ include file=/templates/footer.jsp % !-- END SAMPLE PAGE -- header.jsp looks something like this: !-- BEGIN HEADER.JSP -- % String host = http://; + request.getServerName(); String requestURI = request.getRequestURI(); String pageType = request.getParameter(pageType); String section = thisPage.getSection(); % A bunch of HTML % if (section.equals(foo)) { % %@ include file=/nav/foo.jsp % % } % !-- END HEADER.JSP -- footer.jsp is similar. So are my JSPs dynamic? If so, can I solve my memory problems by switching them to XML docs and using a single JSP page (along with XSLT) to render the pages? Thanks much for your help. Steve -Original Message- From: Will Hartung [mailto:[EMAIL PROTECTED]] Sent: Friday, January 03, 2003 4:54 PM To: Tomcat Users List Subject: Re: Memory Usage and Garbage Collection From: Brandon Cruz [EMAIL PROTECTED] Sent: Friday, January 03, 2003 2:23 PM Subject: RE: Memory Usage and Garbage Collection 1)For every single request to a servlet or JSP page, a new instance of that class is created? For example, if there is one JSP page and ten people access that one page over the course of a day, 10 separate instances of the same class are created and will never be gc'd until the webapp or tomcat is restarted? No no no. Ever so confusing. Here's the rub. First, consider that JSP == Servlet. Second, Servlet == Java Class. When a request comes in for a Servlet, the Servlet class is loaded. Then (assuming we're not using a Single Threaded Model Servlet), a new instance of that Servlet is created to handle the request. These instances of the Servlet will inevitably be GC'd in time. However, what will NOT be GC'd is the CLASS of the Servlet. Once the class is loaded, the class stays around until restart. This is because the ClassLoader for the Servlet hangs on to it. For most applications this is not a problem, as Servlets are roughly equivalent to CGI programs. However, where Servlets are similar to CGI programs, some are equating JSPs with HTML files (or, perhaps better, SHTML files). Most normal sites would have very few CGI programs, but may have loads of HTML or SHTML files. But, since JSPs are actually Servlets in cheap clothing, the JSP == HTML file is not a valid assumption to make. Whereas Servlets are usually mostly just logic, JSPs tend to be mostly content. So, when the server loads the Servlet class generated by the JSP, it loads and caches more content than logic. If Apache remembered and cached every HTML file that went through it, you'd end up potentially caching your entire web tree in RAM. If you happen to have enough RAM to support this, it's not a problem. But if your content is growing every day, and old data doesn't go away, you will eventially run out of RAM and Bad Things will happen. Our site has ~1200 JSPs but all told they only add up to about 6MB, and they're static. So, if all of those managed to get sucked into RAM, the space they would take wouldn't even make a 256MB Tomcat instance blink, so it's not a problem for us. But another fella was generating dynamic JSPs, and would thereby eventually starve out his heap because Tomcat wasn't expiring Servlets. The real question is whether JSPs should be considered Different Enough from normal Servlets to warrant adding code to scavenge them. Regards, Will Hartung ([EMAIL PROTECTED]) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
[LAXMIAKNTH] - MEMORY USAGE
Hi all, I have installed jdk1.3/apache1.3.27/tomcat4.1.12 in RH Linux 7.1.. If I see the process most of the memory more than 80% is occupied by jdk1.3 and so the system is slow and sites which are running there is slowwhat may be the reason thanks in advance Regards Laxmikanth M S Off : 91-80-6610330 extn 1256 http://www.sonata-software.com Coming together is the beginning, staying together is progress and working together is Success What lies behind us and what lies before us are tiny matters compared to what lies within us - Emerson * Disclaimer: The information in this e-mail and any attachments is confidential / privileged. It is intended solely for the addressee or addressees. If you are not the addressee indicated in this message, you may not copy or deliver this message to anyone. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer does not consent to Internet email for messages of this kind. * -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: [LAXMIAKNTH] - MEMORY USAGE
Hi, You can try with IBM JVM, it works well on linux machines incase of performance as well as garbage collection of memory -Original Message- From: Laxmikanth M.S. [mailto:[EMAIL PROTECTED]] Sent: Tue 1/7/2003 4:56 AM To: [EMAIL PROTECTED] Cc: Subject:[LAXMIAKNTH] - MEMORY USAGE Hi all, I have installed jdk1.3/apache1.3.27/tomcat4.1.12 in RH Linux 7.1.. If I see the process most of the memory more than 80% is occupied by jdk1.3 and so the system is slow and sites which are running there is slowwhat may be the reason thanks in advance Regards Laxmikanth M S Off : 91-80-6610330 extn 1256 http://www.sonata-software.com Coming together is the beginning, staying together is progress and working together is Success What lies behind us and what lies before us are tiny matters compared to what lies within us - Emerson * Disclaimer: The information in this e-mail and any attachments is confidential / privileged. It is intended solely for the addressee or addressees. If you are not the addressee indicated in this message, you may not copy or deliver this message to anyone. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer does not consent to Internet email for messages of this kind. * -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] winmail.dat-- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Memory Usage and Garbage Collection
Thanks for that explanation, But i was just curious to know if weakmaps or similar gc interacting cache be used to keep the mem size in control. Servers with high mem size would continue to keep the cache of jsp's for performance whereas the ones with lesser mem size would still not give the outofmemory error. saurabh [EMAIL PROTECTED] 01/04/03 01:12AM On Fri, 3 Jan 2003, Saurabh Arora wrote: Date: Fri, 03 Jan 2003 02:33:17 -0700 From: Saurabh Arora [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: RE: Memory Usage and Garbage Collection Just wanted to know, does the current implementation of tomcat 4.1.18 also has the same problem of keeping the jsp's in memory. or it was only present in 4.0.4 It's not a *problem* -- it's a *feature* :-). This is one of the keys to maintaining good performance on repeatedly requested pages. Yes, Tomcat 4.1.x maintains a reference to every JSP page that has ever been requested (same as every servlet that has ever been requested) until that webapp is reloaded or removed, or you shut down Tomcat. Given this, designing webapps where you auto-generate hundreds of different JSP pages (which was the choice of the originator of this message thread) is not what you really want to do. Instead, you'd want to use a single JSP page for each basic *style* of output (essentially the JSP page would be a formatting template) that pulls in the unique information for a particular report (from the database, from XML, or whatever) dynamically. Then, a given webpp would likely have 5-10 JSP pages, instead of hundreds. Just as an example, assume that your application back-end gave you the data you need in some XML format, and you want to offer your user the chance to format this data in ten different ways. If you create an XSLT stylesheet to transform the data for each of the ten formats, you can do this all with a *single* JSP page that takes an XML data source and an XSLT stylesheet, applies the transformation, and renders the result. (JSTL has a tag that will do all the grunt work for you.) If you really really want to auto-generate all the reports ahead of time, go ahead and generate static HTML pages -- don't waste your time generating JSP that then has to get compiled, loaded, and executed. As a side benefit, the output will get served a little faster because there is less overhead in serving static files. If you really really really want to generate hundreds of JSP pages, then plan on buying enough memory to hold them all and be done with it. Fortunately, this is not usually a break the bank decision (I just upgraded my development PC to a gigabyte of memory for less than $100 :-). If you really really really really want to generate hundreds of JSP pages, and don't (or can't) afford the memory to hold them all, you only have yourself to blame for the results. saurabh Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Memory Usage and Garbage Collection
So the instance, and it's string, can still be GC'd, right? Nope. There is still a live reference to each OtherObject instance sitting in the static HashMap cache. Therefore, this instance cannot be GC'd, even though *you* have released your own reference to it. And, if the OtherObject class is loaded from Tomcat's common/lib directory (for example), there is no way to ***ever*** GC this instance, because the public API of the OtherObject class doesn't offer any way to clear the cache. Wouldn't it be the responsibility of the Factory to worry about releasing objects to the GC? I mean, if it implements caching, it should have some sort of policy when an instantiated (and, thus, cached) object is a candidate for GC. Obvious guidelines are: - if it is not used - if it has last been used less recently than some limit One can also think of a non-linear function, which checks the available memory or has it's internal memory limit. Nix. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Memory Usage and Garbage Collection
Hi Craig, please see intermixed. On 2 Jan 2003 at 18:18, Craig R. McClanahan wrote: Instances can be garbage collected IF AND ONLY IF there are no live references to that object in a static/instance/local variable of some other object that is also in memory. Only instances that are no longer referenced from other object instances can be recycled. Please consider the following service() or doGet() or so of a servlet: public void service(ServletRequest request, ServletResponse response) throws IOException { OtherObject otherObject = new OtherObject(); otherObject.doThisAndThat(request, response); } Do I have to place the following otherObject = null; before the end of service(). Doesn't otherObject be gc-ed otherwise? I've never done this. What about the object instances, which otherObject.doThisAndThat() creates? So far I've thought there are no live references if otherObject gets gc-ed. In the case at hand, Tomcat (obviously) has references to all the servlets that it has loaded. Therefore, those servlet instances cannot be garbage collected. Furthermore, any object that is referenced by static or instance variables of your servlet class can *also* not be garbage collected, because live references still exist. Same thing for session attributes. OK, this is obvious. Andreas deleted the latter parts... -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Memory Usage and Garbage Collection
Just wanted to know, does the current implementation of tomcat 4.1.18 also has the same problem of keeping the jsp's in memory. or it was only present in 4.0.4 saurabh [EMAIL PROTECTED] 01/03/03 02:26PM Hi Craig, please see intermixed. On 2 Jan 2003 at 18:18, Craig R. McClanahan wrote: Instances can be garbage collected IF AND ONLY IF there are no live references to that object in a static/instance/local variable of some other object that is also in memory. Only instances that are no longer referenced from other object instances can be recycled. Please consider the following service() or doGet() or so of a servlet: public void service(ServletRequest request, ServletResponse response) throws IOException { OtherObject otherObject = new OtherObject(); otherObject.doThisAndThat(request, response); } Do I have to place the following otherObject = null; before the end of service(). Doesn't otherObject be gc-ed otherwise? I've never done this. What about the object instances, which otherObject.doThisAndThat() creates? So far I've thought there are no live references if otherObject gets gc-ed. In the case at hand, Tomcat (obviously) has references to all the servlets that it has loaded. Therefore, those servlet instances cannot be garbage collected. Furthermore, any object that is referenced by static or instance variables of your servlet class can *also* not be garbage collected, because live references still exist. Same thing for session attributes. OK, this is obvious. Andreas deleted the latter parts... -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Memory Usage and Garbage Collection
Hi, There's clearly some misconceptions on the topic of garbage collection ;) These questions come up very often it seems, on this list and others. Please consider the following service() or doGet() or so of a servlet: public void service(ServletRequest request, ServletResponse response) throws IOException { OtherObject otherObject = new OtherObject(); otherObject.doThisAndThat(request, response); } Do I have to place the following otherObject = null; before the end of service(). Doesn't otherObject be gc-ed otherwise? I've never done this. You don't have to do this. The otherObject's reference count is increase by one when you assign it. When the method (service() above) returns, the reference count for otherObject is reduced by one. If the reference count is zero, otherObject can be garbage collected. What about the object instances, which otherObject.doThisAndThat() creates? So far I've thought there are no live references if otherObject gets gc-ed. If otherObject creates local objects, they'll be GCed. If it modifies static objects, those objects stay in a different place anyways and don't get GCed when otherObject does. Back to what Craig mentioned earlier: earlier in the Java life time, classes could get GCed themselves. That really earns you very little, so it was removed. Nowadays demands on classloaders and their hierarchies can get very complicated, so re-introducing class GC would be difficult anyways. A JSP is compiled into a servlet and then loaded into memory. Its bytecode is present only once, and takes up relatively little space (usually). You won't gain much from destroying that bytecode and de-allocating its memory. Same thing for normal servlets obviouisly. What you need to do is tune your garbage collection. With some exceptions, full GCs shouldn't run all the time. Depending on your collector, partial GCs can run all the time. You'd expect that from incremental and concurrent collectors. If you're running on multiple CPUs and have a parallel collector but only one System.out log, you'd expect to see GC output there nearly all the time. So you should start playing with your heap (-Xmx), new generation size and ration (XX:NewSize, XX:MaxNewSize, XX:NewRatio), collector policy (-Xincgc, -Xconcgc, XX:UseParNewGC, etc.) and other parameters to see which gives you the best behavior. Don't -Xmx over the physical RAM size. See the VM options page at: http://java.sun.com/docs/hotspot/VMOptions.html One principle to keep in mind is that memory is cheap, or at least considered cheap when it comes to GC performance tuning. The java heap is greedy overall, and this is intended to increaser performance. That's why it won't de-allocate space (and never return space to the OS) until necessary with the default mark/sweep collector. Make sure to record your verbose:gc output between runs so that you can compare behavior. This is not typically easy to tell by instinctive feel. Yoav Shapira Millennium ChemInformatics -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Memory Usage and Garbage Collection
Hi thank you, your reply calms me down again. I guess I got a bit confused by the preceding discussion. Andreas On 3 Jan 2003 at 8:59, Shapira, Yoav wrote: Hi, There's clearly some misconceptions on the topic of garbage collection ;) These questions come up very often it seems, on this list and others. Please consider the following service() or doGet() or so of a servlet: public void service(ServletRequest request, ServletResponse response) throws IOException { OtherObject otherObject = new OtherObject(); otherObject.doThisAndThat(request, response); } Do I have to place the following otherObject = null; before the end of service(). Doesn't otherObject be gc-ed otherwise? I've never done this. You don't have to do this. The otherObject's reference count is increase by one when you assign it. When the method (service() above) returns, the reference count for otherObject is reduced by one. If the reference count is zero, otherObject can be garbage collected. What about the object instances, which otherObject.doThisAndThat() creates? So far I've thought there are no live references if otherObject gets gc-ed. If otherObject creates local objects, they'll be GCed. If it modifies static objects, those objects stay in a different place anyways and don't get GCed when otherObject does. Back to what Craig mentioned earlier: earlier in the Java life time, classes could get GCed themselves. That really earns you very little, so it was removed. Nowadays demands on classloaders and their hierarchies can get very complicated, so re-introducing class GC would be difficult anyways. A JSP is compiled into a servlet and then loaded into memory. Its bytecode is present only once, and takes up relatively little space (usually). You won't gain much from destroying that bytecode and de-allocating its memory. Same thing for normal servlets obviouisly. What you need to do is tune your garbage collection. With some exceptions, full GCs shouldn't run all the time. Depending on your collector, partial GCs can run all the time. You'd expect that from incremental and concurrent collectors. If you're running on multiple CPUs and have a parallel collector but only one System.out log, you'd expect to see GC output there nearly all the time. So you should start playing with your heap (-Xmx), new generation size and ration (XX:NewSize, XX:MaxNewSize, XX:NewRatio), collector policy (-Xincgc, -Xconcgc, XX:UseParNewGC, etc.) and other parameters to see which gives you the best behavior. Don't -Xmx over the physical RAM size. See the VM options page at: http://java.sun.com/docs/hotspot/VMOptions.html One principle to keep in mind is that memory is cheap, or at least considered cheap when it comes to GC performance tuning. The java heap is greedy overall, and this is intended to increaser performance. That's why it won't de-allocate space (and never return space to the OS) until necessary with the default mark/sweep collector. Make sure to record your verbose:gc output between runs so that you can compare behavior. This is not typically easy to tell by instinctive feel. Yoav Shapira Millennium ChemInformatics -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Memory Usage and Garbage Collection
On Fri, 3 Jan 2003, Andreas Probst wrote: Hi Craig, please see intermixed. On 2 Jan 2003 at 18:18, Craig R. McClanahan wrote: Instances can be garbage collected IF AND ONLY IF there are no live references to that object in a static/instance/local variable of some other object that is also in memory. Only instances that are no longer referenced from other object instances can be recycled. Please consider the following service() or doGet() or so of a servlet: public void service(ServletRequest request, ServletResponse response) throws IOException { OtherObject otherObject = new OtherObject(); otherObject.doThisAndThat(request, response); } Do I have to place the following otherObject = null; before the end of service(). Doesn't otherObject be gc-ed otherwise? I've never done this. The otherObject reference goes away as soon as the service() method returns, so you don't have to actually release it yourself. HOWEVER, you also need to understand what the constructor of this class did, and what the doThisAndThat() method did -- it's still possible for that class to cause memory leaks which you don't know anything about, or possibly can't do anything about. What about the object instances, which otherObject.doThisAndThat() creates? So far I've thought there are no live references if otherObject gets gc-ed. Let's look at a simple case and a complex case: SIMPLE CASE: OtherObject has a single instance variable that is initialized to a String: public class OtherObject { private String id; public OtherObject(String id) { this.id = id; } public String getId() { return (this.id); } } In this case, the only reference to the String pointed at by id is in this instance of OtherObject. Therefore, when you release your reference to the OtherObject instance and the id string that was passed in (because the service() method ended), both the OtherObject instance and the foo String instance are available for GC. COMPLEX CASE: OtherObject is a little trickier in its initialization -- it provides a factory pattern method that creates at most one instance of OtherObject for a particular identifier string. (This is a *very* common design pattern -- in fact, Tomcat implements something sort of like this to ensure that there is at most one instance of each servlet class.) public class OtherObject { // Private constructor -- use the factory method instead private OtherObject(String id) { this.id = id; } // Private instance variable -- one per instance private String id; // Public getter for the id property public String getId() { return (this.id); } // Static cache of previously created instances private static HashMap cache = new HashMap(); // Factory method for creating OtherObject instances that // guarantees to create only one for a particular id string public static OtherObject getOtherObject(String id) { synchronized (cache) { OtherObject instance = (OtherObject) cache.get(id); if (instance == null) { instance = new OtherObject(id); cache.put(id, instance); } return (instance); } } } To use the factory method, you'd say something like this: OtherObject otherObject = OtherObject.getOtherObject(idstring); instead of: OtherObject otherObject = new OtherObject(idstring); and, no matter how many times you call this with the same parameter value, you'd get the same instance back (basically a singleton pattern with lazy instantiation). Now, your otherObject reference still goes away at the end of the service() method, right? Yep. So the instance, and it's string, can still be GC'd, right? Nope. There is still a live reference to each OtherObject instance sitting in the static HashMap cache. Therefore, this instance cannot be GC'd, even though *you* have released your own reference to it. And, if the OtherObject class is loaded from Tomcat's common/lib directory (for example), there is no way to ***ever*** GC this instance, because the public API of the OtherObject class doesn't offer any way to clear the cache. Note also that there is nothing that your servlet can do about this -- you can't even know if its happening without consulting the documentation and/or the source code for the classes you are calling. But the code above will cause a slowly increasing consumption of memory over time (assuming that you're asking for different id values), even though *you* are not maintaining any live references to these objects. Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Memory Usage and Garbage Collection
On Fri, 3 Jan 2003, Saurabh Arora wrote: Date: Fri, 03 Jan 2003 02:33:17 -0700 From: Saurabh Arora [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: RE: Memory Usage and Garbage Collection Just wanted to know, does the current implementation of tomcat 4.1.18 also has the same problem of keeping the jsp's in memory. or it was only present in 4.0.4 It's not a *problem* -- it's a *feature* :-). This is one of the keys to maintaining good performance on repeatedly requested pages. Yes, Tomcat 4.1.x maintains a reference to every JSP page that has ever been requested (same as every servlet that has ever been requested) until that webapp is reloaded or removed, or you shut down Tomcat. Given this, designing webapps where you auto-generate hundreds of different JSP pages (which was the choice of the originator of this message thread) is not what you really want to do. Instead, you'd want to use a single JSP page for each basic *style* of output (essentially the JSP page would be a formatting template) that pulls in the unique information for a particular report (from the database, from XML, or whatever) dynamically. Then, a given webpp would likely have 5-10 JSP pages, instead of hundreds. Just as an example, assume that your application back-end gave you the data you need in some XML format, and you want to offer your user the chance to format this data in ten different ways. If you create an XSLT stylesheet to transform the data for each of the ten formats, you can do this all with a *single* JSP page that takes an XML data source and an XSLT stylesheet, applies the transformation, and renders the result. (JSTL has a tag that will do all the grunt work for you.) If you really really want to auto-generate all the reports ahead of time, go ahead and generate static HTML pages -- don't waste your time generating JSP that then has to get compiled, loaded, and executed. As a side benefit, the output will get served a little faster because there is less overhead in serving static files. If you really really really want to generate hundreds of JSP pages, then plan on buying enough memory to hold them all and be done with it. Fortunately, this is not usually a break the bank decision (I just upgraded my development PC to a gigabyte of memory for less than $100 :-). If you really really really really want to generate hundreds of JSP pages, and don't (or can't) afford the memory to hold them all, you only have yourself to blame for the results. saurabh Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Memory Usage and Garbage Collection
Hi Craig, thank you very much for this complete explanation. That's perfectly understandable and the GC-behaviour which I had expected before. I must have understood something wrong in this thread's discussion, which went on yesterday. Again, thank you very much for your helpful responses (not only this one). Andreas On 3 Jan 2003 at 11:31, Craig R. McClanahan wrote: On Fri, 3 Jan 2003, Andreas Probst wrote: Hi Craig, please see intermixed. On 2 Jan 2003 at 18:18, Craig R. McClanahan wrote: Instances can be garbage collected IF AND ONLY IF there are no live references to that object in a static/instance/local variable of some other object that is also in memory. Only instances that are no longer referenced from other object instances can be recycled. Please consider the following service() or doGet() or so of a servlet: public void service(ServletRequest request, ServletResponse response) throws IOException { OtherObject otherObject = new OtherObject(); otherObject.doThisAndThat(request, response); } Do I have to place the following otherObject = null; before the end of service(). Doesn't otherObject be gc-ed otherwise? I've never done this. The otherObject reference goes away as soon as the service() method returns, so you don't have to actually release it yourself. HOWEVER, you also need to understand what the constructor of this class did, and what the doThisAndThat() method did -- it's still possible for that class to cause memory leaks which you don't know anything about, or possibly can't do anything about. What about the object instances, which otherObject.doThisAndThat() creates? So far I've thought there are no live references if otherObject gets gc-ed. Let's look at a simple case and a complex case: SIMPLE CASE: OtherObject has a single instance variable that is initialized to a String: public class OtherObject { private String id; public OtherObject(String id) { this.id = id; } public String getId() { return (this.id); } } In this case, the only reference to the String pointed at by id is in this instance of OtherObject. Therefore, when you release your reference to the OtherObject instance and the id string that was passed in (because the service() method ended), both the OtherObject instance and the foo String instance are available for GC. COMPLEX CASE: OtherObject is a little trickier in its initialization -- it provides a factory pattern method that creates at most one instance of OtherObject for a particular identifier string. (This is a *very* common design pattern -- in fact, Tomcat implements something sort of like this to ensure that there is at most one instance of each servlet class.) public class OtherObject { // Private constructor -- use the factory method instead private OtherObject(String id) { this.id = id; } // Private instance variable -- one per instance private String id; // Public getter for the id property public String getId() { return (this.id); } // Static cache of previously created instances private static HashMap cache = new HashMap(); // Factory method for creating OtherObject instances that // guarantees to create only one for a particular id string public static OtherObject getOtherObject(String id) { synchronized (cache) { OtherObject instance = (OtherObject) cache.get(id); if (instance == null) { instance = new OtherObject(id); cache.put(id, instance); } return (instance); } } } To use the factory method, you'd say something like this: OtherObject otherObject = OtherObject.getOtherObject(idstring); instead of: OtherObject otherObject = new OtherObject(idstring); and, no matter how many times you call this with the same parameter value, you'd get the same instance back (basically a singleton pattern with lazy instantiation). Now, your otherObject reference still goes away at the end of the service() method, right? Yep. So the instance, and it's string, can still be GC'd, right? Nope. There is still a live reference to each OtherObject instance sitting in the static HashMap cache. Therefore, this instance cannot be GC'd, even though *you* have released your own reference to it. And, if the OtherObject class is loaded from Tomcat's common/lib directory (for example), there is no way to ***ever*** GC this instance, because the public API of the OtherObject class doesn't offer any way to clear the cache. Note also that there is nothing that your servlet can do about this -- you can't even know if its happening without consulting the documentation and/or the source code for the classes you are calling. But the code above will cause a slowly increasing
RE: Memory Usage and Garbage Collection
Craig, From what you have been saying... 1)For every single request to a servlet or JSP page, a new instance of that class is created? For example, if there is one JSP page and ten people access that one page over the course of a day, 10 separate instances of the same class are created and will never be gc'd until the webapp or tomcat is restarted? 2)If this is true, it looks to me like any java application in the world eventually has to be restarted as more and more people access it. Buying more memory would prolong the time to restart the application, but eventually all the instances created will take up all the available RAM. Is this correct? Brandon -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Friday, January 03, 2003 1:43 PM To: Tomcat Users List Subject: RE: Memory Usage and Garbage Collection On Fri, 3 Jan 2003, Saurabh Arora wrote: Date: Fri, 03 Jan 2003 02:33:17 -0700 From: Saurabh Arora [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: RE: Memory Usage and Garbage Collection Just wanted to know, does the current implementation of tomcat 4.1.18 also has the same problem of keeping the jsp's in memory. or it was only present in 4.0.4 It's not a *problem* -- it's a *feature* :-). This is one of the keys to maintaining good performance on repeatedly requested pages. Yes, Tomcat 4.1.x maintains a reference to every JSP page that has ever been requested (same as every servlet that has ever been requested) until that webapp is reloaded or removed, or you shut down Tomcat. Given this, designing webapps where you auto-generate hundreds of different JSP pages (which was the choice of the originator of this message thread) is not what you really want to do. Instead, you'd want to use a single JSP page for each basic *style* of output (essentially the JSP page would be a formatting template) that pulls in the unique information for a particular report (from the database, from XML, or whatever) dynamically. Then, a given webpp would likely have 5-10 JSP pages, instead of hundreds. Just as an example, assume that your application back-end gave you the data you need in some XML format, and you want to offer your user the chance to format this data in ten different ways. If you create an XSLT stylesheet to transform the data for each of the ten formats, you can do this all with a *single* JSP page that takes an XML data source and an XSLT stylesheet, applies the transformation, and renders the result. (JSTL has a tag that will do all the grunt work for you.) If you really really want to auto-generate all the reports ahead of time, go ahead and generate static HTML pages -- don't waste your time generating JSP that then has to get compiled, loaded, and executed. As a side benefit, the output will get served a little faster because there is less overhead in serving static files. If you really really really want to generate hundreds of JSP pages, then plan on buying enough memory to hold them all and be done with it. Fortunately, this is not usually a break the bank decision (I just upgraded my development PC to a gigabyte of memory for less than $100 :-). If you really really really really want to generate hundreds of JSP pages, and don't (or can't) afford the memory to hold them all, you only have yourself to blame for the results. saurabh Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Memory Usage and Garbage Collection
From: Brandon Cruz [EMAIL PROTECTED] Sent: Friday, January 03, 2003 2:23 PM Subject: RE: Memory Usage and Garbage Collection 1)For every single request to a servlet or JSP page, a new instance of that class is created? For example, if there is one JSP page and ten people access that one page over the course of a day, 10 separate instances of the same class are created and will never be gc'd until the webapp or tomcat is restarted? No no no. Ever so confusing. Here's the rub. First, consider that JSP == Servlet. Second, Servlet == Java Class. When a request comes in for a Servlet, the Servlet class is loaded. Then (assuming we're not using a Single Threaded Model Servlet), a new instance of that Servlet is created to handle the request. These instances of the Servlet will inevitably be GC'd in time. However, what will NOT be GC'd is the CLASS of the Servlet. Once the class is loaded, the class stays around until restart. This is because the ClassLoader for the Servlet hangs on to it. For most applications this is not a problem, as Servlets are roughly equivalent to CGI programs. However, where Servlets are similar to CGI programs, some are equating JSPs with HTML files (or, perhaps better, SHTML files). Most normal sites would have very few CGI programs, but may have loads of HTML or SHTML files. But, since JSPs are actually Servlets in cheap clothing, the JSP == HTML file is not a valid assumption to make. Whereas Servlets are usually mostly just logic, JSPs tend to be mostly content. So, when the server loads the Servlet class generated by the JSP, it loads and caches more content than logic. If Apache remembered and cached every HTML file that went through it, you'd end up potentially caching your entire web tree in RAM. If you happen to have enough RAM to support this, it's not a problem. But if your content is growing every day, and old data doesn't go away, you will eventially run out of RAM and Bad Things will happen. Our site has ~1200 JSPs but all told they only add up to about 6MB, and they're static. So, if all of those managed to get sucked into RAM, the space they would take wouldn't even make a 256MB Tomcat instance blink, so it's not a problem for us. But another fella was generating dynamic JSPs, and would thereby eventually starve out his heap because Tomcat wasn't expiring Servlets. The real question is whether JSPs should be considered Different Enough from normal Servlets to warrant adding code to scavenge them. Regards, Will Hartung ([EMAIL PROTECTED]) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Memory Usage and Garbage Collection
On Fri, 3 Jan 2003, Brandon Cruz wrote: Date: Fri, 3 Jan 2003 16:23:24 -0600 From: Brandon Cruz [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED], [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: RE: Memory Usage and Garbage Collection Craig, From what you have been saying... 1)For every single request to a servlet or JSP page, a new instance of that class is created? NO! It's exactly the opposite -- the same instance gets reused every time. For example, if there is one JSP page and ten people access that one page over the course of a day, 10 separate instances of the same class are created and will never be gc'd until the webapp or tomcat is restarted? 2)If this is true, it looks to me like any java application in the world eventually has to be restarted as more and more people access it. Buying more memory would prolong the time to restart the application, but eventually all the instances created will take up all the available RAM. Is this correct? The point I was trying to make is that code you *call* from your servlets and JSPs can create memory leaks, and there's not necessarily anything that you (as the author of the servlet or JSP) page can do about it. You can't even tell that it's happening unless you have access to the source code of the classes you're calling. Assume that you implement something like the complex example from my previous mail, and every call to the getOtherObject() method specifies a different id value. The old OtherObject instances will *not* be GC'd, because there are live references to them -- even if they are not in your servlet, they still exist in the JVM. And the fact that there is only one instance of your servlet is not relevant to this memory leak, because it is not your servlet instances that are being accumulated. It is not good enough to just release references in your servlet when you are through with an object. Brandon Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Memory Usage and Garbage Collection
The same servlet gets called everytime? Isn't this container implementation specific (Although functionally it SHOULD appear to be the same servlet)? For example, couldn't a container do pooling or load balancing. Craig R. McClanahan wrote: On Fri, 3 Jan 2003, Brandon Cruz wrote: Date: Fri, 3 Jan 2003 16:23:24 -0600 From: Brandon Cruz [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED], [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: RE: Memory Usage and Garbage Collection Craig, From what you have been saying... 1)For every single request to a servlet or JSP page, a new instance of that class is created? NO! It's exactly the opposite -- the same instance gets reused every time. For example, if there is one JSP page and ten people access that one page over the course of a day, 10 separate instances of the same class are created and will never be gc'd until the webapp or tomcat is restarted? 2)If this is true, it looks to me like any java application in the world eventually has to be restarted as more and more people access it. Buying more memory would prolong the time to restart the application, but eventually all the instances created will take up all the available RAM. Is this correct? The point I was trying to make is that code you *call* from your servlets and JSPs can create memory leaks, and there's not necessarily anything that you (as the author of the servlet or JSP) page can do about it. You can't even tell that it's happening unless you have access to the source code of the classes you're calling. Assume that you implement something like the complex example from my previous mail, and every call to the getOtherObject() method specifies a different id value. The old OtherObject instances will *not* be GC'd, because there are live references to them -- even if they are not in your servlet, they still exist in the JVM. And the fact that there is only one instance of your servlet is not relevant to this memory leak, because it is not your servlet instances that are being accumulated. It is not good enough to just release references in your servlet when you are through with an object. Brandon Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- = = Management is doing things right; leadership is doing the = = right things.- Peter Drucker= =___= = http://www.sun.com/service/sunps/jdc/javacenter.pdf = = www.sun.com | www.javasoft.com | http://wwws.sun.com/sunone = = -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Memory Usage and Garbage Collection
Instead, you'd want to use a single JSP page for each basic *style* of output (essentially the JSP page would be a formatting template) that pulls in the unique information for a particular report (from the database, from XML, or whatever) dynamically. For example, with the web site for The Mahogany Man (http://www.the-mahogany-man.com), the entire catalog is a single JSP page. There are 100s of items in the catalog. --- Noel -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Memory Usage and Garbage Collection
There is still a live reference to each OtherObject instance sitting in the static HashMap cache. there is no way to ***ever*** GC this instance Another example of a similar memory leak is the File.deleteOnExit method. It should not be used without extreme care and understanding in a server application, since the system has to hold onto memory related to deleting the file until the JVM shuts down. --- Noel -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
top command shows memory usage of java process is two times more than what actually java heap is taking
Hi, When I run top command on linux, it is showing memory usage of java process is two times more than what java heap is taking, I got java heap size inside java program using Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); I didn't understand why it is showing like this, Can anybody explain me Thks, --Venkat winmail.dat-- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Memory Usage and Garbage Collection
Do loaded jsp pages and/or class files ever get garbage collected when tomcat is running? We have a production server with several hundred virtual hosts per host, each with a fair share of jsp pages and with moderate to low traffic per host. As time goes on, the amount of memory being used constantly grows. It starts off around 60MB, then goes higher and higher, getting up to around 100MB after a couple days. The regular GC seems to usually clean up around 2MB ([GC 99493K-97502K(204544K), 0.0243521 secs]) and the Full GC seems to clean up less than that ([Full GC 97388K-97187K(204544K), 2.4269915 secs]). Since I have the -Xmx and -Xms set to 200MB, the 204544K number never gets resized, but the number before the - seems to slowly and steadily rise. Full GC seems to run quite often, every few seconds, GC runs once in a while, but spits out about 50 lines at once every time it runs. Is this normal? Shouldn't Full GC only run once in a while? I am starting to think that as classes and jsp's are loaded, they stay in memory and are never released until tomcat is restarted, which means that there is eventually a point where all the classes will load and I just need to have enough memory to support that without having to use swap space. The problem occurs when the memory usage number before the - gets up to about 130. The system is using swap space and eventually out of memory errors start showing up. Any ideas? More Ram, more tuning, different site architecture? Thanks in advance? Brandon -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Memory Usage and Garbage Collection
On Thu, 2 Jan 2003, Brandon Cruz wrote: Date: Thu, 2 Jan 2003 16:16:23 -0600 From: Brandon Cruz [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED], [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Memory Usage and Garbage Collection Do loaded jsp pages and/or class files ever get garbage collected when tomcat is running? It's legal for servlet containers to destroy and release servlets and JSP pages while the server is running, but Tomcat doesn't currently do so. Once a servlet or JSP is loaded, it stays loaded until you reload that particular webapp or you shut Tomcat down. We have a production server with several hundred virtual hosts per host, each with a fair share of jsp pages and with moderate to low traffic per host. As time goes on, the amount of memory being used constantly grows. It starts off around 60MB, then goes higher and higher, getting up to around 100MB after a couple days. The regular GC seems to usually clean up around 2MB ([GC 99493K-97502K(204544K), 0.0243521 secs]) and the Full GC seems to clean up less than that ([Full GC 97388K-97187K(204544K), 2.4269915 secs]). Since I have the -Xmx and -Xms set to 200MB, the 204544K number never gets resized, but the number before the - seems to slowly and steadily rise. Full GC seems to run quite often, every few seconds, GC runs once in a while, but spits out about 50 lines at once every time it runs. Is this normal? Shouldn't Full GC only run once in a while? I am starting to think that as classes and jsp's are loaded, they stay in memory and are never released until tomcat is restarted, which means that there is eventually a point where all the classes will load and I just need to have enough memory to support that without having to use swap space. It's not just the classes -- it's the object instances created from those classes that take up space (the bytecodes of the class itself exist only once). The problem occurs when the memory usage number before the - gets up to about 130. The system is using swap space and eventually out of memory errors start showing up. Any ideas? More Ram, more tuning, different site architecture? If you're using swap space, you probably have your max heap size (-Xmx) too large for the amount of physical memory that is available. I'd definitely start by either reducing -Xmx or increasing the amount of physical RAM. If reducing -Xmx gives you OutOfMemoryException errors, then increasing RAM is the only option. The second thing I'd do is review my applications for places where they might be maintaining references to data in between requests, either in instance variables of the servlet or JSP class or by keeping too many things in the user's session for too long. If there are such references, your user data objects cannot be GC'd and you'll end up with exactly the pattern you describe (slowly increasing memory use). Thanks in advance? Brandon Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Memory Usage and Garbage Collection
Craig, Thanks for your comments, I still have a few clarification questions. 1)It's not just the classes -- it's the object instances created from those classes that take up space (the bytecodes of the class itself exist only once). ---does this mean that every object instance is never garbage collected, or are these instances collected? 2)What about instances of the classes, does every instance stay in memory forever? Are they loaded into the sessions, or are they pooled somehow? What about the instance variables of these classes, I assume they get collected after the class instances would be collected. If class instances stay in memory forever, I would think there is no possible way to ever keep the system running without a restart. Brandon -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 02, 2003 6:12 PM To: Tomcat Users List; [EMAIL PROTECTED] Subject: Re: Memory Usage and Garbage Collection On Thu, 2 Jan 2003, Brandon Cruz wrote: Date: Thu, 2 Jan 2003 16:16:23 -0600 From: Brandon Cruz [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED], [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Memory Usage and Garbage Collection Do loaded jsp pages and/or class files ever get garbage collected when tomcat is running? It's legal for servlet containers to destroy and release servlets and JSP pages while the server is running, but Tomcat doesn't currently do so. Once a servlet or JSP is loaded, it stays loaded until you reload that particular webapp or you shut Tomcat down. We have a production server with several hundred virtual hosts per host, each with a fair share of jsp pages and with moderate to low traffic per host. As time goes on, the amount of memory being used constantly grows. It starts off around 60MB, then goes higher and higher, getting up to around 100MB after a couple days. The regular GC seems to usually clean up around 2MB ([GC 99493K-97502K(204544K), 0.0243521 secs]) and the Full GC seems to clean up less than that ([Full GC 97388K-97187K(204544K), 2.4269915 secs]). Since I have the -Xmx and -Xms set to 200MB, the 204544K number never gets resized, but the number before the - seems to slowly and steadily rise. Full GC seems to run quite often, every few seconds, GC runs once in a while, but spits out about 50 lines at once every time it runs. Is this normal? Shouldn't Full GC only run once in a while? I am starting to think that as classes and jsp's are loaded, they stay in memory and are never released until tomcat is restarted, which means that there is eventually a point where all the classes will load and I just need to have enough memory to support that without having to use swap space. It's not just the classes -- it's the object instances created from those classes that take up space (the bytecodes of the class itself exist only once). The problem occurs when the memory usage number before the - gets up to about 130. The system is using swap space and eventually out of memory errors start showing up. Any ideas? More Ram, more tuning, different site architecture? If you're using swap space, you probably have your max heap size (-Xmx) too large for the amount of physical memory that is available. I'd definitely start by either reducing -Xmx or increasing the amount of physical RAM. If reducing -Xmx gives you OutOfMemoryException errors, then increasing RAM is the only option. The second thing I'd do is review my applications for places where they might be maintaining references to data in between requests, either in instance variables of the servlet or JSP class or by keeping too many things in the user's session for too long. If there are such references, your user data objects cannot be GC'd and you'll end up with exactly the pattern you describe (slowly increasing memory use). Thanks in advance? Brandon Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Memory Usage and Garbage Collection
Looking at the jasper source of tomcat 4.0.4 releasing jsp's seems to be reasonable easy to implement: The Jsp's classloader, the class and the actual jsp-servlet instance are all put together in a JspServletWrapper-Object which itself is stored in the JspServlet (the Servlet used to executing jsps) using a Hashtable. One could replace the hashtable with a LRU-Cache or anything. Since each jsp is loaded using a separate classloader, removing the Wrapper removes the reference to the instance, it's class and it's loader, which should enable the class garbage collector to remove the class. Do you think this approach is reasonable? Does this part of the implementation differ with Jasper2? This is a feature I could really use well. llap, julian - Original Message - From: Craig R. McClanahan [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Friday, January 03, 2003 1:12 AM Subject: Re: Memory Usage and Garbage Collection On Thu, 2 Jan 2003, Brandon Cruz wrote: Date: Thu, 2 Jan 2003 16:16:23 -0600 From: Brandon Cruz [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED], [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Memory Usage and Garbage Collection Do loaded jsp pages and/or class files ever get garbage collected when tomcat is running? It's legal for servlet containers to destroy and release servlets and JSP pages while the server is running, but Tomcat doesn't currently do so. Once a servlet or JSP is loaded, it stays loaded until you reload that particular webapp or you shut Tomcat down. We have a production server with several hundred virtual hosts per host, each with a fair share of jsp pages and with moderate to low traffic per host. As time goes on, the amount of memory being used constantly grows. It starts off around 60MB, then goes higher and higher, getting up to around 100MB after a couple days. The regular GC seems to usually clean up around 2MB ([GC 99493K-97502K(204544K), 0.0243521 secs]) and the Full GC seems to clean up less than that ([Full GC 97388K-97187K(204544K), 2.4269915 secs]). Since I have the -Xmx and -Xms set to 200MB, the 204544K number never gets resized, but the number before the - seems to slowly and steadily rise. Full GC seems to run quite often, every few seconds, GC runs once in a while, but spits out about 50 lines at once every time it runs. Is this normal? Shouldn't Full GC only run once in a while? I am starting to think that as classes and jsp's are loaded, they stay in memory and are never released until tomcat is restarted, which means that there is eventually a point where all the classes will load and I just need to have enough memory to support that without having to use swap space. It's not just the classes -- it's the object instances created from those classes that take up space (the bytecodes of the class itself exist only once). The problem occurs when the memory usage number before the - gets up to about 130. The system is using swap space and eventually out of memory errors start showing up. Any ideas? More Ram, more tuning, different site architecture? If you're using swap space, you probably have your max heap size (-Xmx) too large for the amount of physical memory that is available. I'd definitely start by either reducing -Xmx or increasing the amount of physical RAM. If reducing -Xmx gives you OutOfMemoryException errors, then increasing RAM is the only option. The second thing I'd do is review my applications for places where they might be maintaining references to data in between requests, either in instance variables of the servlet or JSP class or by keeping too many things in the user's session for too long. If there are such references, your user data objects cannot be GC'd and you'll end up with exactly the pattern you describe (slowly increasing memory use). Thanks in advance? Brandon Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Memory Usage and Garbage Collection
On Thu, 2 Jan 2003, Brandon Cruz wrote: Date: Thu, 2 Jan 2003 19:04:55 -0600 From: Brandon Cruz [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: Memory Usage and Garbage Collection Craig, Thanks for your comments, I still have a few clarification questions. 1)It's not just the classes -- it's the object instances created from those classes that take up space (the bytecodes of the class itself exist only once). ---does this mean that every object instance is never garbage collected, or are these instances collected? Instances can be garbage collected IF AND ONLY IF there are no live references to that object in a static/instance/local variable of some other object that is also in memory. Only instances that are no longer referenced from other object instances can be recycled. In the case at hand, Tomcat (obviously) has references to all the servlets that it has loaded. Therefore, those servlet instances cannot be garbage collected. Furthermore, any object that is referenced by static or instance variables of your servlet class can *also* not be garbage collected, because live references still exist. Same thing for session attributes. In the very early days of Java, classes themselves could be GC'd if there were no live instances of that class. However, this caused more grief than it was worth, so that went away (about JDK 1.1 or so). In today's world, the only way to throw away a class instance is to throw away the class loader that loaded it (which is how Tomcat implements webapp reloading). 2)What about instances of the classes, does every instance stay in memory forever? Are they loaded into the sessions, or are they pooled somehow? What about the instance variables of these classes, I assume they get collected after the class instances would be collected. As above, instances ALWAYS stay in memory as long as there are live references. If there are no live references, the GC is free to clean them up if and when it feels like it. If class instances stay in memory forever, I would think there is no possible way to ever keep the system running without a restart. As above, you can throw away references to a ClassLoader, and that will ultimately cause all the instances to be collected -- but ONLY if there are not any references to any instances of classes loaded by that ClassLoader somewhere else. Phew, that doesn't make sense -- can we describe a sample use case? Sure. Consider the fact that Tomcat provides more than one class loader (see http://jakarta.apache.org/tomcat/tomcat-4.1-doc/class-loader-howto.html). The common and shared class loaders are never thrown away, so any classes loaded from there will stay in memory for the lifetime of Tomcat. But wait, there's more. Assume that you've got a class, loaded from a library in common/lib, that maintains a collection as a static variable. Now, assume you've called a method on this class, and passed it a reference to a bean (or something) that is loaded from your webapp (i.e. it's in WEB-INF/classes or WEB-INF/lib), and this reference gets added to the static collection. Now, ask Tomcat to reload this application. What happens? Tomcat dutifully throws away its reference to the webapp class loader. Normally, that means everything loaded from that class loader is now garbage and can be collected. HOWEVER, because there is still a live reference to one of the objects from your old webapp in the static collection. Therefore, GC cannot process: * The instance of your bean class that was referenced * The class of your bean * The webapp class loader * Any other objects referenced by the webapp class loader. In short, the above scenario just created a memory leak. The best thing you can do to avoid problems like this is to make your webapps self contained, and to always release references to objects you don't need any longer. Brandon Craig -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 02, 2003 6:12 PM To: Tomcat Users List; [EMAIL PROTECTED] Subject: Re: Memory Usage and Garbage Collection On Thu, 2 Jan 2003, Brandon Cruz wrote: Date: Thu, 2 Jan 2003 16:16:23 -0600 From: Brandon Cruz [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED], [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Memory Usage and Garbage Collection Do loaded jsp pages and/or class files ever get garbage collected when tomcat is running? It's legal for servlet containers to destroy and release servlets and JSP pages while the server is running, but Tomcat doesn't currently do so. Once a servlet or JSP is loaded, it stays loaded until you reload that particular webapp or you shut Tomcat down. We have a production server with several hundred virtual hosts per host, each with a fair share of jsp pages and with moderate to low traffic per host. As time goes
Re: Memory Usage and Garbage Collection
On Fri, 3 Jan 2003, Julian Löffelhardt wrote: Date: Fri, 3 Jan 2003 02:01:58 +0100 From: Julian Löffelhardt [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Re: Memory Usage and Garbage Collection Looking at the jasper source of tomcat 4.0.4 releasing jsp's seems to be reasonable easy to implement: The Jsp's classloader, the class and the actual jsp-servlet instance are all put together in a JspServletWrapper-Object which itself is stored in the JspServlet (the Servlet used to executing jsps) using a Hashtable. One could replace the hashtable with a LRU-Cache or anything. Since each jsp is loaded using a separate classloader, removing the Wrapper removes the reference to the instance, it's class and it's loader, which should enable the class garbage collector to remove the class. Do you think this approach is reasonable? Does this part of the implementation differ with Jasper2? You'd best examine the sources to figure that out :-). But Jasper2 is radically different than Jasper1. But remember, it's not just a matter of throwing away the reference to the compiled servlet class. You also need to ensure that the destroy() method gets called as the servlet API requires -- all the while ensuring that no additional requests start getting processed through the service method. And, don't forget that this will harm performance for the vast majority of users who *do* have adequate memory on their servers, so nothing like this should be enabled by default. This is a feature I could really use well. llap, julian Craig - Original Message - From: Craig R. McClanahan [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Friday, January 03, 2003 1:12 AM Subject: Re: Memory Usage and Garbage Collection On Thu, 2 Jan 2003, Brandon Cruz wrote: Date: Thu, 2 Jan 2003 16:16:23 -0600 From: Brandon Cruz [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED], [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Memory Usage and Garbage Collection Do loaded jsp pages and/or class files ever get garbage collected when tomcat is running? It's legal for servlet containers to destroy and release servlets and JSP pages while the server is running, but Tomcat doesn't currently do so. Once a servlet or JSP is loaded, it stays loaded until you reload that particular webapp or you shut Tomcat down. We have a production server with several hundred virtual hosts per host, each with a fair share of jsp pages and with moderate to low traffic per host. As time goes on, the amount of memory being used constantly grows. It starts off around 60MB, then goes higher and higher, getting up to around 100MB after a couple days. The regular GC seems to usually clean up around 2MB ([GC 99493K-97502K(204544K), 0.0243521 secs]) and the Full GC seems to clean up less than that ([Full GC 97388K-97187K(204544K), 2.4269915 secs]). Since I have the -Xmx and -Xms set to 200MB, the 204544K number never gets resized, but the number before the - seems to slowly and steadily rise. Full GC seems to run quite often, every few seconds, GC runs once in a while, but spits out about 50 lines at once every time it runs. Is this normal? Shouldn't Full GC only run once in a while? I am starting to think that as classes and jsp's are loaded, they stay in memory and are never released until tomcat is restarted, which means that there is eventually a point where all the classes will load and I just need to have enough memory to support that without having to use swap space. It's not just the classes -- it's the object instances created from those classes that take up space (the bytecodes of the class itself exist only once). The problem occurs when the memory usage number before the - gets up to about 130. The system is using swap space and eventually out of memory errors start showing up. Any ideas? More Ram, more tuning, different site architecture? If you're using swap space, you probably have your max heap size (-Xmx) too large for the amount of physical memory that is available. I'd definitely start by either reducing -Xmx or increasing the amount of physical RAM. If reducing -Xmx gives you OutOfMemoryException errors, then increasing RAM is the only option. The second thing I'd do is review my applications for places where they might be maintaining references to data in between requests, either in instance variables of the servlet or JSP class or by keeping too many things in the user's session for too long. If there are such references, your user data objects cannot be GC'd and you'll end up with exactly the pattern you describe (slowly increasing memory use). Thanks in advance? Brandon Craig
Tomcat 4.1.12 Memory Usage
Hi all, Earlier I installed tomcat3.3.1 with apache1.3.27 ...the performance of the machine was better... Now I have installed Tomcat4.1.12 with apache1.3.27 the system Memory usage is full and almost it hangsis this the problem with tomcat4.1.12...do i need to do some extra setting to improve the performance or is this a bug in 4.1.12 version. thanks Laxmikanth * Disclaimer: The information in this e-mail and any attachments is confidential / privileged. It is intended solely for the addressee or addressees. If you are not the addressee indicated in this message, you may not copy or deliver this message to anyone. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer does not consent to Internet email for messages of this kind. * -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Memory usage?
This is probably a more general java question: My long-running Tomcat processes become huge. I have the max heap set to -Xmx512m, yet after a day or so the virtual size of java reaches upwards of 2GB, and the resident size sometimes exceeds 1GB. Shouldn't I get OutOfMemoryErrors sooner? If it's not heap, what is in all that extra space? I'm pretty certain that I just need to reduce my session timeout (it's way too long, and we get a _lot_ of traffic). But the JVM behavior surprises me. This is with the Sun JDK 1.4.1_01 on Linux. Thanks, Jeff Schnitzer [EMAIL PROTECTED] The Sims Online -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Memory usage?
you using JDBC? Head of Operations AsiaPac elata Level 30 6 Battery Road Singapore 049909 Office : +65 65509723 Mobile : +65 91117814 Fax: +65 65509725 [EMAIL PROTECTED] http://www.elata.com This e-mail is intended solely for the above mentioned recipient(s) and it may contain confidential information. If you have received this e-mail in error, please notify us immediately and delete the e-mail from your system. Copying, distribution or other use of the information contained in this e-mail is strictly prohibited. Nothing in this e-mail amounts to a contractual commitment, or is otherwise legally binding on elata unless confirmed by an authorised representative independently of this e-mail. Registered in England, number 1961405 -Original Message- From: Schnitzer, Jeff [mailto:[EMAIL PROTECTED]] Sent: 04 December 2002 12:59 To: [EMAIL PROTECTED] Subject: Memory usage? This is probably a more general java question: My long-running Tomcat processes become huge. I have the max heap set to -Xmx512m, yet after a day or so the virtual size of java reaches upwards of 2GB, and the resident size sometimes exceeds 1GB. Shouldn't I get OutOfMemoryErrors sooner? If it's not heap, what is in all that extra space? I'm pretty certain that I just need to reduce my session timeout (it's way too long, and we get a _lot_ of traffic). But the JVM behavior surprises me. This is with the Sun JDK 1.4.1_01 on Linux. Thanks, Jeff Schnitzer [EMAIL PROTECTED] The Sims Online -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Memory usage?
Ah, yes, of course - the oracle oci drivers have a native code component. Yuck. Thanks! Jeff Schnitzer [EMAIL PROTECTED] The Sims Online -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 03, 2002 11:00 PM To: Tomcat Users List Subject: RE: Memory usage? you using JDBC? Head of Operations AsiaPac elata Level 30 6 Battery Road Singapore 049909 Office : +65 65509723 Mobile : +65 91117814 Fax: +65 65509725 [EMAIL PROTECTED] http://www.elata.com This e-mail is intended solely for the above mentioned recipient(s) and it may contain confidential information. If you have received this e-mail in error, please notify us immediately and delete the e-mail from your system. Copying, distribution or other use of the information contained in this e-mail is strictly prohibited. Nothing in this e-mail amounts to a contractual commitment, or is otherwise legally binding on elata unless confirmed by an authorised representative independently of this e-mail. Registered in England, number 1961405 -Original Message- From: Schnitzer, Jeff [mailto:[EMAIL PROTECTED]] Sent: 04 December 2002 12:59 To: [EMAIL PROTECTED] Subject: Memory usage? This is probably a more general java question: My long-running Tomcat processes become huge. I have the max heap set to -Xmx512m, yet after a day or so the virtual size of java reaches upwards of 2GB, and the resident size sometimes exceeds 1GB. Shouldn't I get OutOfMemoryErrors sooner? If it's not heap, what is in all that extra space? I'm pretty certain that I just need to reduce my session timeout (it's way too long, and we get a _lot_ of traffic). But the JVM behavior surprises me. This is with the Sun JDK 1.4.1_01 on Linux. Thanks, Jeff Schnitzer [EMAIL PROTECTED] The Sims Online -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] For additional commands, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Displaying servlets and its memory usage
Hi, OptimizeIt 5.0, the newest, claims to be able to display this sort of thing, if your servlets are each a different class, which is normally the case. But keep in mind all you'll see, with any of today's tools that I know of, is the memory usage of the servlet instance itself, not including any member variables it holds. For example, if com.mycompany.MyServlet has five instances in memory, each holding a String[1000] array, you would see the five instances as one memory total, and the String[] as 5000 separate things. Older tools don't even support that much information. In general, using JPDA/JVMPI to get hierarchical (as opposed to flat, which all tools do) memory information is currently next to impossible. Yoav Shapira Millennium ChemInformatics -Original Message- From: Sriraman.R [mailto:[EMAIL PROTECTED]] Sent: Sunday, November 24, 2002 6:38 AM To: tomcat Subject: FW: Displaying servlets and its memory usage Any clues/pointers to get this info! -Sriram -Original Message- From: Sriraman.R [mailto:[EMAIL PROTECTED]] Sent: Friday, November 22, 2002 7:18 PM To: Tomcat Users List Subject: Displaying servlets and its memory usage hi all, I have tomcat 3.2.4 and few servlets running. I want to see the memory usage of each serlvet running. However I get memory hogging often. I would like to find which servlet is causing this problem. Is there a tool/java program to dump each servlet and its memory usage periodically,say every 10 secs like NT's Task Manager. Appreciate any help asap! thanks, -Sriram -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] For additional commands, e-mail: mailto:tomcat-user- [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
FW: Displaying servlets and its memory usage
Any clues/pointers to get this info! -Sriram -Original Message- From: Sriraman.R [mailto:[EMAIL PROTECTED]] Sent: Friday, November 22, 2002 7:18 PM To: Tomcat Users List Subject: Displaying servlets and its memory usage hi all, I have tomcat 3.2.4 and few servlets running. I want to see the memory usage of each serlvet running. However I get memory hogging often. I would like to find which servlet is causing this problem. Is there a tool/java program to dump each servlet and its memory usage periodically,say every 10 secs like NT's Task Manager. Appreciate any help asap! thanks, -Sriram -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Displaying servlets and its memory usage
Borland's OptimizeIt is very good at this, but it costs. Sriraman.R [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Any clues/pointers to get this info! -Sriram -Original Message- From: Sriraman.R [mailto:[EMAIL PROTECTED]] Sent: Friday, November 22, 2002 7:18 PM To: Tomcat Users List Subject: Displaying servlets and its memory usage hi all, I have tomcat 3.2.4 and few servlets running. I want to see the memory usage of each serlvet running. However I get memory hogging often. I would like to find which servlet is causing this problem. Is there a tool/java program to dump each servlet and its memory usage periodically,say every 10 secs like NT's Task Manager. Appreciate any help asap! thanks, -Sriram -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Displaying servlets and its memory usage
hi all, I have tomcat 3.2.4 and few servlets running. I want to see the memory usage of each serlvet running. However I get memory hogging often. I would like to find which servlet is causing this problem. Is there a tool/java program to dump each servlet and its memory usage periodically,say every 10 secs like NT's Task Manager. Appreciate any help asap! thanks, -Sriram -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Tomcat memory usage
Hmmm - looks like Brandon asked a similar question while I was writing this one! Have read replies, but would appreciate anyone offering any explanation for what we're seeing. Noticed that several of the replies uses multiple tomcats. Is this recommended? We're just using a single server. thanks, David [EMAIL PROTECTED] on 10/24/2002 03:47:45 PM Please respond to Tomcat Users List [EMAIL PROTECTED] To:Tomcat Users List [EMAIL PROTECTED] cc: Subject:Tomcat memory usage Hi. Would anyone be able to explain some details about Tomcat memory usage when it is being installed and run as a service (NT, 2000, XP). When we repeatedly upload forms, we are seeing the memory usage and Virtual Memory size in the Task Manager grow and grow and grow. Sometimes when we run another memory-hungry application, the Memory Usage for tomcat drops way down (presumably as this is the actual working set size, and it is getting swapped out), but sometimes (with dual processor machine, though not sure that makes any difference) it refuses to give up memory, or does so extremely slowly (having raised tomcat to 200 MB). We are pretty sure that there are no leaks in our java code, and only small leaks in the native libraries we are using. Does anyone have any insight / explanation / advice? Many thanks, David -- To unsubscribe, e-mail: mailto:tomcat-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:tomcat-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-user-help;jakarta.apache.org