RE: Memory Allocation
Howdy, Whoa there ;) Be very careful about some things: - The amount of memory tomcat takes on startup is variable. This changes with tomcat version, OS version, JDK version, configured webapps and their listeners / filters / load-on-startup servlets, any Loggers/Valves/Realms configured for tomcat in server.xml, etc. As you can see this is many variables. - Using a debugger such as JProbe or OptimizeIt may inflate the memory usage of a system by a factor of 10 or more. - What the other guy said about the default heap set at 64MB -- the default heap MAXIMUM is set as 64MB. The default minimum is very small, again depending on JDK version and flags used. For an illustration, try the following: - Set -Xmx10m in your JAVA_OPTS to allow only 10MB on the heap. - Start tomcat without a debugger. You shouldn't have a problem. - Try to start tomcat with a debugger. See what happens ;) Yoav Shapira Millennium ChemInformatics -Original Message- From: Hari Venkatesan [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 21, 2003 4:21 PM To: [EMAIL PROTECTED] Subject: Memory Allocation Tomcat when starting uses 60M memory in heap. Why is that it is using so much memory in heap. I found this by running jprobe memory debugger. I have just one application in the context of server.xml file and don't think the entire application gets loaded into memory. After doing a full garbage collection, the heap memory comes down to 11M. Is something going wrong or is it the way tomcat behaves? Hari -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Memory Allocation
Shapira, Thanks for your suggestion. When you startup Tomcat with -Xms10m and -Xmx10m it does a lot of Full GC before it can bring up and finally settles down to use 7.2megs using a debugger. Without a debugger tomcat still comes up after doing a lot of Full GC's. I have just one application in my context in my server.xml and have just 2 load-on-startup servlets which is not big (one gets the roles from ldap server which loads a maximum of 5 roles and the other starts up log4j. No Realms have been defined. I use Win2k, Tomcat 4.1.12 and JDK 1.3.1_06. Without Using jprobe or OptimizeIt is there a way to check how much memory has been used. Hari -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 22, 2003 9:29 AM To: Tomcat Users List Subject: RE: Memory Allocation Howdy, Whoa there ;) Be very careful about some things: - The amount of memory tomcat takes on startup is variable. This changes with tomcat version, OS version, JDK version, configured webapps and their listeners / filters / load-on-startup servlets, any Loggers/Valves/Realms configured for tomcat in server.xml, etc. As you can see this is many variables. - Using a debugger such as JProbe or OptimizeIt may inflate the memory usage of a system by a factor of 10 or more. - What the other guy said about the default heap set at 64MB -- the default heap MAXIMUM is set as 64MB. The default minimum is very small, again depending on JDK version and flags used. For an illustration, try the following: - Set -Xmx10m in your JAVA_OPTS to allow only 10MB on the heap. - Start tomcat without a debugger. You shouldn't have a problem. - Try to start tomcat with a debugger. See what happens ;) Yoav Shapira Millennium ChemInformatics -Original Message- From: Hari Venkatesan [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 21, 2003 4:21 PM To: [EMAIL PROTECTED] Subject: Memory Allocation Tomcat when starting uses 60M memory in heap. Why is that it is using so much memory in heap. I found this by running jprobe memory debugger. I have just one application in the context of server.xml file and don't think the entire application gets loaded into memory. After doing a full garbage collection, the heap memory comes down to 11M. Is something going wrong or is it the way tomcat behaves? Hari -- 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 Allocation
Hi, No Realms have been defined. I use Win2k, Tomcat 4.1.12 and JDK 1.3.1_06. Have you tried this across different JVM? I'd be curious about that. Without Using jprobe or OptimizeIt is there a way to check how much memory has been used. Runtime.getRuntime().freeMemory(); Runtime.getRuntime().totalMemory(); Yoav Shapira Millennium ChemInformatics -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Memory Allocation
Hi, I can try with IBM's version and also with sun's JVM1.4.1_01 and let you know about it. Thanks for your input. Hari -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 22, 2003 10:36 AM To: Tomcat Users List Subject: RE: Memory Allocation Hi, No Realms have been defined. I use Win2k, Tomcat 4.1.12 and JDK 1.3.1_06. Have you tried this across different JVM? I'd be curious about that. Without Using jprobe or OptimizeIt is there a way to check how much memory has been used. Runtime.getRuntime().freeMemory(); Runtime.getRuntime().totalMemory(); Yoav Shapira Millennium ChemInformatics -- 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 Allocation
Its probably set in the jvm - the default heap size set is for 64 meg. This can be changed using the -Xmx parmeters in the initial call to the jvm. We set the max heap size for our tomcat to 128M using: -Xmx128M -Original Message- From: Hari Venkatesan [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 21, 2003 1:21 PM To: [EMAIL PROTECTED] Subject: Memory Allocation Tomcat when starting uses 60M memory in heap. Why is that it is using so much memory in heap. I found this by running jprobe memory debugger. I have just one application in the context of server.xml file and don't think the entire application gets loaded into memory. After doing a full garbage collection, the heap memory comes down to 11M. Is something going wrong or is it the way tomcat behaves? Hari
RE: Memory Allocation
I have a -Xms set to 128m and -Xmx set to 256. But does tomcat itself takes 60M of 128M? ? ? Hari -Original Message- From: Tolles, James [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 21, 2003 4:26 PM To: 'Tomcat Users List' Subject: RE: Memory Allocation Its probably set in the jvm - the default heap size set is for 64 meg. This can be changed using the -Xmx parmeters in the initial call to the jvm. We set the max heap size for our tomcat to 128M using: -Xmx128M -Original Message- From: Hari Venkatesan [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 21, 2003 1:21 PM To: [EMAIL PROTECTED] Subject: Memory Allocation Tomcat when starting uses 60M memory in heap. Why is that it is using so much memory in heap. I found this by running jprobe memory debugger. I have just one application in the context of server.xml file and don't think the entire application gets loaded into memory. After doing a full garbage collection, the heap memory comes down to 11M. Is something going wrong or is it the way tomcat behaves? Hari -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: memory allocation
Not to worry. The only time that I know you need to set objects to null is when you write servers and inside you (while (true).. eternal loop. - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, June 14, 2001 1:41 PM Subject: memory allocation hi all , i want to ask something about jsp pages sample jsp code = ** %@ page import = "java.util.*" % %@ page import = "MyBean" % %@ page contentType="text/html;charset=ISO-8859-9" % jsp:useBean id="my_bean" class="MyBean" scope="page"/ html head % ArrayList al = new ArrayList(); mybean.showData(al); // we are going to fill ArrayList Iterator it = al.iterator(); while( it.hasNext() ) { % %=(String)it.next()% % } //while al = null ; // should i do this ? or is it going to be garbage collected by itself it = null ; // shoul i do this ? or is it going to be garbage collected by itself % /head /html ** my_bean object will be garbage collected because it' scope is page but what about ArrayList and Iterator objects ? thanks Regards Altug B. Altntas
RE: memory allocation
The only time you need to set a variable to null is when the variable itself sticks around (e.g., a class variable, or an instance variable on some object on a class variable). You never have to null out local variables. This is a general Java question, not a Tomcat question. If my answer didn't make sense, ask on news:comp.lang.java.programmer, or on a Java mailing list. -- Bill K. -Original Message- From: Luba Powell [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 14, 2001 12:11 PM To: [EMAIL PROTECTED] Subject: Re: memory allocation Not to worry. The only time that I know you need to set objects to null is when you write servers and inside you (while (true).. eternal loop. - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, June 14, 2001 1:41 PM Subject: memory allocation hi all , i want to ask something about jsp pages sample jsp code = ** %@ page import = java.util.* % %@ page import = MyBean % %@ page contentType=text/html;charset=ISO-8859-9 % jsp:useBean id=my_bean class=MyBean scope=page/ html head % ArrayList al = new ArrayList(); mybean.showData(al); // we are going to fill ArrayList Iterator it = al.iterator(); while( it.hasNext() ) { % %=(String)it.next()% % } //while al = null ; // should i do this ? or is it going to be garbage collected by itself it = null ; // shoul i do this ? or is it going to be garbage collected by itself % /head /html ** my_bean object will be garbage collected because it' scope is page but what about ArrayList and Iterator objects ? thanks Regards Altug B. Altintas
RE: memory allocation
um.. i'm pretty sure that it doesn't matter. the system garbage collector MAY reap memory for objects that are set to null. remember once the service method executes all the method variables ( al it ) go out of scope and are elegible for gc. if you had static or class level members using %! % tags then they would not be gc until their references were nullafied. hope this helps. warren. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, 15 June 2001 5:09 AM To: [EMAIL PROTECTED] Subject: memory allocation hi all , i want to ask something about jsp pages sample jsp code = ** %@ page import = "java.util.*" % %@ page import = "MyBean" % %@ page contentType="text/html;charset=ISO-8859-9" % jsp:useBean id="my_bean" class="MyBean" scope="page"/ html head % ArrayList al = new ArrayList(); mybean.showData(al); // we are going to fill ArrayList Iterator it = al.iterator(); while( it.hasNext() ) { % %=(String)it.next()% % } //while al = null ; // should i do this ? or is it going to be garbage collected by itself it = null ; // shoul i do this ? or is it going to be garbage collected by itself % /head /html ** my_bean object will be garbage collected because it' scope is page but what about ArrayList and Iterator objects ? thanks Regards Altug