Re: Garbage Collection
Thanx a lott.. This is exactly what I was looking for!! I have used all local variables. :-) Regards, Vibha - Original Message - From: Anton Tagunov <[EMAIL PROTECTED]> To: Vibha Jindal <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Thursday, January 31, 2002 11:08 PM Subject: Re: Garbage Collection > Hello Vibha! > > VJ> Hi, > > VJ> I am creating instances of dataclasses in my Servlets and JSPs. > VJ> I am not explicitly setting them to null after use. > VJ> Could this be a problem? > VJ> I mean, would these objects not be eligible for garbage collection or would > VJ> they be eligible? > > It depends. If you put references to classes to variables that have > method-scope (that is local ones in doGet() f.e.) there's no problem. > If you store them to class instance or static variables the objects > are retained. But you have no reason to assign to static/class > variables. > > With JSP what you declare inside <%! %> become class instance > variables, best do not use them at all! > What you declare inside <% %> are local variables. > > Good luck! > VJ> Regards, > VJ> Vibha > > > - Anton > [EMAIL PROTECTED] > [EMAIL PROTECTED] > > === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://archives.java.sun.com/jsp-interest.html http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.jsp http://www.jguru.com/faq/index.jsp http://www.jspinsider.com
Re: Garbage Collection
Hello Vibha! VJ> Hi, VJ> I am creating instances of dataclasses in my Servlets and JSPs. VJ> I am not explicitly setting them to null after use. VJ> Could this be a problem? VJ> I mean, would these objects not be eligible for garbage collection or would VJ> they be eligible? It depends. If you put references to classes to variables that have method-scope (that is local ones in doGet() f.e.) there's no problem. If you store them to class instance or static variables the objects are retained. But you have no reason to assign to static/class variables. With JSP what you declare inside <%! %> become class instance variables, best do not use them at all! What you declare inside <% %> are local variables. Good luck! VJ> Regards, VJ> Vibha - Anton [EMAIL PROTECTED] [EMAIL PROTECTED] === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://archives.java.sun.com/jsp-interest.html http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.jsp http://www.jguru.com/faq/index.jsp http://www.jspinsider.com
Re: Garbage Collection
You don't need to set null explicitly if you are not code that init method your servlet.The container will create and destroy the for every invocation of your servlet's or JSp's service method. - Original Message - From: "Vibha Jindal" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 31, 2002 11:46 AM Subject: Re: Garbage Collection > Hi, > > I was intereested in knowing the effect in Servlets and JSPs. > I believe that the Servlets are destroyed as soon as they throw the JSP. > > And once the JSP displays the HTML, I guess it loses scope. So, all objects > initialised in these JSPs and servlets should not require me to set the > references to null. > Or do I need to ? > > Regards, > Vibha > > - Original Message - > From: Vikramjit Singh <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, January 31, 2002 9:32 AM > Subject: Re: Garbage Collection > > > > hi vibha, > > > > the objects will be eligible for garbagecollection if it is unreachable > i.e. > > no object references to that particular object. It is always better to put > > your object references to null. You cannot be sure that setting the object > > references to null, they will be garbage collected but they will become a > > candidate for garbage collection. > > I always do like this for resultsets, statements and connections in the > > finally block. For more information on garbage collection you can read > some > > core java books. > > > > finally > > { > > if (rs != null) > > { > > rs.close(); > > rs = null; > > } > > } > > > > Vikramjit Singh, > > Systems Engineer, > > GTL Ltd. > > Ph. 7612929-3140 > > > > > > -Original Message- > > From: Vibha Jindal [mailto:[EMAIL PROTECTED]] > > Sent: Wednesday, January 30, 2002 7:59 PM > > To: [EMAIL PROTECTED] > > Subject: Garbage Collection > > > > > > Hi, > > > > I am creating instances of dataclasses in my Servlets and JSPs. > > I am not explicitly setting them to null after use. > > Could this be a problem? > > I mean, would these objects not be eligible for garbage collection or > would > > they be eligible? > > > > Regards, > > Vibha > > > > > === > > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff > > JSP-INTEREST". > > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST > > DIGEST". > > Some relevant FAQs on JSP/Servlets can be found at: > > > > http://archives.java.sun.com/jsp-interest.html > > http://java.sun.com/products/jsp/faq.html > > http://www.esperanto.org.nz/jsp/jspfaq.jsp > > http://www.jguru.com/faq/index.jsp > > http://www.jspinsider.com > > > > > === > > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff > JSP-INTEREST". > > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST > DIGEST". > > Some relevant FAQs on JSP/Servlets can be found at: > > > > http://archives.java.sun.com/jsp-interest.html > > http://java.sun.com/products/jsp/faq.html > > http://www.esperanto.org.nz/jsp/jspfaq.jsp > > http://www.jguru.com/faq/index.jsp > > http://www.jspinsider.com > > === > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". > Some relevant FAQs on JSP/Servlets can be found at: > > http://archives.java.sun.com/jsp-interest.html > http://java.sun.com/products/jsp/faq.html > http://www.esperanto.org.nz/jsp/jspfaq.jsp > http://www.jguru.com/faq/index.jsp > http://www.jspinsider.com > === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://archives.java.sun.com/jsp-interest.html http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.jsp http://www.jguru.com/faq/index.jsp http://www.jspinsider.com
Re: Garbage Collection
Hi, I was intereested in knowing the effect in Servlets and JSPs. I believe that the Servlets are destroyed as soon as they throw the JSP. And once the JSP displays the HTML, I guess it loses scope. So, all objects initialised in these JSPs and servlets should not require me to set the references to null. Or do I need to ? Regards, Vibha - Original Message - From: Vikramjit Singh <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, January 31, 2002 9:32 AM Subject: Re: Garbage Collection > hi vibha, > > the objects will be eligible for garbagecollection if it is unreachable i.e. > no object references to that particular object. It is always better to put > your object references to null. You cannot be sure that setting the object > references to null, they will be garbage collected but they will become a > candidate for garbage collection. > I always do like this for resultsets, statements and connections in the > finally block. For more information on garbage collection you can read some > core java books. > > finally > { > if (rs != null) > { > rs.close(); > rs = null; > } > } > > Vikramjit Singh, > Systems Engineer, > GTL Ltd. > Ph. 7612929-3140 > > > -Original Message- > From: Vibha Jindal [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, January 30, 2002 7:59 PM > To: [EMAIL PROTECTED] > Subject: Garbage Collection > > > Hi, > > I am creating instances of dataclasses in my Servlets and JSPs. > I am not explicitly setting them to null after use. > Could this be a problem? > I mean, would these objects not be eligible for garbage collection or would > they be eligible? > > Regards, > Vibha > > === > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff > JSP-INTEREST". > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST > DIGEST". > Some relevant FAQs on JSP/Servlets can be found at: > > http://archives.java.sun.com/jsp-interest.html > http://java.sun.com/products/jsp/faq.html > http://www.esperanto.org.nz/jsp/jspfaq.jsp > http://www.jguru.com/faq/index.jsp > http://www.jspinsider.com > > === > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". > Some relevant FAQs on JSP/Servlets can be found at: > > http://archives.java.sun.com/jsp-interest.html > http://java.sun.com/products/jsp/faq.html > http://www.esperanto.org.nz/jsp/jspfaq.jsp > http://www.jguru.com/faq/index.jsp > http://www.jspinsider.com === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://archives.java.sun.com/jsp-interest.html http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.jsp http://www.jguru.com/faq/index.jsp http://www.jspinsider.com
Re: Garbage Collection
hi vibha, the objects will be eligible for garbagecollection if it is unreachable i.e. no object references to that particular object. It is always better to put your object references to null. You cannot be sure that setting the object references to null, they will be garbage collected but they will become a candidate for garbage collection. I always do like this for resultsets, statements and connections in the finally block. For more information on garbage collection you can read some core java books. finally { if (rs != null) { rs.close(); rs = null; } } Vikramjit Singh, Systems Engineer, GTL Ltd. Ph. 7612929-3140 -Original Message- From: Vibha Jindal [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 30, 2002 7:59 PM To: [EMAIL PROTECTED] Subject: Garbage Collection Hi, I am creating instances of dataclasses in my Servlets and JSPs. I am not explicitly setting them to null after use. Could this be a problem? I mean, would these objects not be eligible for garbage collection or would they be eligible? Regards, Vibha === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://archives.java.sun.com/jsp-interest.html http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.jsp http://www.jguru.com/faq/index.jsp http://www.jspinsider.com === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://archives.java.sun.com/jsp-interest.html http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.jsp http://www.jguru.com/faq/index.jsp http://www.jspinsider.com
Re: Garbage collection issue - URGENT
piyush, I don't know anything about iplanet web server, so I can't comment on how iplanet works. Again, I'm not an expert on JRUN, but it is my understanding that all JSP's and servlets are loaded into memory the first time that particulary page is hit/called by JRUN. This is why the first time you hit a large JSP page, it might take a few seconds for it to display, and then all subsequent hits/calls will run faster, as it is calling the page resident in memory. As to releasing memory via setting all references to null, or calling a garbage collector, you can do this with an OBJECT you are referencing in your JSP, but to my knowledge, you can't set a JSP to null. For example, you can call a database object in your JSP page Driver database = DriverManager.getDriver(); // use the db for a while database = null; This will release the memory that the database object is using (via the JVM), but it does NOT unload the JSP page (at least to my knowledge it does not). I don't know of anyway to "release" a JSP page from memory. Does anyone else have any comment on this? Celeste -Original Message- From: A mailing list about Java Server Pages specification and reference [mailto:[EMAIL PROTECTED]]On Behalf Of piyush jain Sent: Thursday, May 03, 2001 11:49 PM To: [EMAIL PROTECTED] Subject: Re: Garbage collection issue - URGENT Celeste, I wanted to understand that if that is the case then should i explicitly run the garbage collector or set all the references to null in all the jsp's? how would i identify the references which would be occupying the memory?? i am using iplanet web server. it would be same that also i supp.. piyush. - Original Message -- Celeste Haseltine <[EMAIL PROTECTED]> wrote: To:[EMAIL PROTECTED] From:Celeste Haseltine <[EMAIL PROTECTED]> Date:Thu, 3 May 2001 09:46:22 -0500 Subject:Re: Garbage collection issue - URGENT Rathna, Please double check what I am about to say on the Allaire developer web site, but I think that you have a misunderstanding of how a JSP complier/interpreter works, which is what JRUN is. In Java, you do a have garbage collection, such that when an object is no longer being "referenced" by anything else, the garbage collector comes in behind the scene and deallocates memory for you. But that is NOT how JRUN server works. It is a JSP interpreter/complier, and as such, when you "hit" a JSP page, that page is compiled into a servlet, and is then stored in memory. It remains in memory UNTIL you either restart you server, or change the JSP(at which time it is re-compiled). To my knowledge, JRUN server NEVER deallocates memory related to the JSP's or the servelets. Because of this, you sometimes get bizarre behavior when you change your JSP's often enough WITHOUT stopping and restarting the JRUN server during the development phase. That is one reason why I always stop and restart my JRUN server when I change either a JSP or a Servlet. I want to make sure that the previous copy has been "wiped" out of memory. Please note that this is NOT how your Java Objects/Beans are handled. The "references" to those objects and beans are deallocated by the JVM. Remember, the JVM is NOT compiling/interpreting your JSP or servelets, it is JRUN. Again, make sure that I am correct on this by posting to the Allaire developers web site/discussion group for JRUN 3.0. Good luck!!! Celeste -Original Message- From: A mailing list about Java Server Pages specification and reference [mailto:[EMAIL PROTECTED]]On Behalf Of Rathna Sent: Thursday, May 03, 2001 8:01 AM To: [EMAIL PROTECTED] Subject: Garbage collection issue - URGENT Hi all, I wonder is there any garbage collection problem in Jrun 3.0 version. we are using JDK 1.2.2 in jrun 3.0 version on solarix box. In the long run the application becomes very slow.we have 1GB of swap space and after running the jrun(after several hit) the swap space reduced to nearly 15MB.so i have a feeling that the Jrun is not releasing the memory correctly. Is there any know memory issue in Jrun 3.0? FYI,we have said the heap size as 512MB for Jrun. Thanks in advance. -- Cheers, rathna === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] wi
Re: Garbage collection issue - URGENT
Rathna, First off, if you have not already done so, I would contact/post a note on the JRUN developer discussion group and with their support group and find out if there is someway to configure JRUN to release memory. But I still question why you would want to do this. If you release the JSP/servelets from memory, you will have to recompile/reload them every time, and that will slow down your web site. The next thing I would do would be to take a hard look at your JSP's and see if you are doing business logic/processes that would be better separated into a Java object/bean class, and then call and use the bean class in your JSP as required. Since the JVM will release the memory that the bean occupies when it is no longer being referenced, this might help out. Remember, the JSP should be for presentation only, all business logic that can be separated out into a Java class should be. After doing the above two steps, I would take a look at your server. Is it an old, outdated machine? Are you running/hosting other processes on it, and if so, can the server handle the additional load of hosting your web site? Do you need to just purchase more memory for the server? I don't know what type of server your using, it's configuration, and how much memory you obtained when you purchased the server, and whether you are using the server to run other web sites/processes other than the one your working on. If you have a network admin/hardware guru, you may want to solicit their input and find out if the server has enough memory to run the web site that you are developing, particularly if you are running/hosting other processes on it. Hope this helps! Celeste -Original Message- From: A mailing list about Java Server Pages specification and reference [mailto:[EMAIL PROTECTED]]On Behalf Of Rathna Sent: Friday, May 04, 2001 12:17 AM To: [EMAIL PROTECTED] Subject: Re: Garbage collection issue - URGENT hi celeste, In our application , we use large number of JSP's say around 300. Will there be a problem for Jrun to load all the servlets into the memory in the long run?.Does jrun has the mechanism of unloading the servlet if it is not referenced for longer time? with regards, rathna. Celeste Haseltine wrote: > Rathna, > > Please double check what I am about to say on the Allaire developer web > site, but I think that you have a misunderstanding of how a JSP > complier/interpreter works, which is what JRUN is. > > In Java, you do a have garbage collection, such that when an object is no > longer being "referenced" by anything else, the garbage collector comes in > behind the scene and deallocates memory for you. But that is NOT how JRUN > server works. It is a JSP interpreter/complier, and as such, when you "hit" > a JSP page, that page is compiled into a servlet, and is then stored in > memory. It remains in memory UNTIL you either restart you server, or change > the JSP(at which time it is re-compiled). To my knowledge, JRUN server > NEVER deallocates memory related to the JSP's or the servelets. Because of > this, you sometimes get bizarre behavior when you change your JSP's often > enough WITHOUT stopping and restarting the JRUN server during the > development phase. That is one reason why I always stop and restart my JRUN > server when I change either a JSP or a Servlet. I want to make sure that > the previous copy has been "wiped" out of memory. Please note that this is > NOT how your Java Objects/Beans are handled. The "references" to those > objects and beans are deallocated by the JVM. Remember, the JVM is NOT > compiling/interpreting your JSP or servelets, it is JRUN. > > Again, make sure that I am correct on this by posting to the Allaire > developers web site/discussion group for JRUN 3.0. > > Good luck!!! > > Celeste > > -Original Message- > From: A mailing list about Java Server Pages specification and reference > [mailto:[EMAIL PROTECTED]]On Behalf Of Rathna > Sent: Thursday, May 03, 2001 8:01 AM > To: [EMAIL PROTECTED] > Subject: Garbage collection issue - URGENT > > Hi all, > > I wonder is there any garbage collection problem in Jrun 3.0 version. > we are using JDK 1.2.2 in jrun 3.0 version on solarix box. In the long > run > the application becomes very slow.we have 1GB of swap space > and after running the jrun(after several hit) the swap space reduced to > nearly > 15MB.so i have a feeling that the Jrun is not releasing the memory > correctly. > > Is there any know memory issue in Jrun 3.0? > FYI,we have said the heap size as 512MB for Jrun. > > Thanks in advance. > > -- > Cheers, > rathna > > === > To unsubscribe: ma
Re: Garbage collection issue - URGENT
hi celeste, In our application , we use large number of JSP's say around 300. Will there be a problem for Jrun to load all the servlets into the memory in the long run?.Does jrun has the mechanism of unloading the servlet if it is not referenced for longer time? with regards, rathna. Celeste Haseltine wrote: > Rathna, > > Please double check what I am about to say on the Allaire developer web > site, but I think that you have a misunderstanding of how a JSP > complier/interpreter works, which is what JRUN is. > > In Java, you do a have garbage collection, such that when an object is no > longer being "referenced" by anything else, the garbage collector comes in > behind the scene and deallocates memory for you. But that is NOT how JRUN > server works. It is a JSP interpreter/complier, and as such, when you "hit" > a JSP page, that page is compiled into a servlet, and is then stored in > memory. It remains in memory UNTIL you either restart you server, or change > the JSP(at which time it is re-compiled). To my knowledge, JRUN server > NEVER deallocates memory related to the JSP's or the servelets. Because of > this, you sometimes get bizarre behavior when you change your JSP's often > enough WITHOUT stopping and restarting the JRUN server during the > development phase. That is one reason why I always stop and restart my JRUN > server when I change either a JSP or a Servlet. I want to make sure that > the previous copy has been "wiped" out of memory. Please note that this is > NOT how your Java Objects/Beans are handled. The "references" to those > objects and beans are deallocated by the JVM. Remember, the JVM is NOT > compiling/interpreting your JSP or servelets, it is JRUN. > > Again, make sure that I am correct on this by posting to the Allaire > developers web site/discussion group for JRUN 3.0. > > Good luck!!! > > Celeste > > -Original Message- > From: A mailing list about Java Server Pages specification and reference > [mailto:[EMAIL PROTECTED]]On Behalf Of Rathna > Sent: Thursday, May 03, 2001 8:01 AM > To: [EMAIL PROTECTED] > Subject: Garbage collection issue - URGENT > > Hi all, > > I wonder is there any garbage collection problem in Jrun 3.0 version. > we are using JDK 1.2.2 in jrun 3.0 version on solarix box. In the long > run > the application becomes very slow.we have 1GB of swap space > and after running the jrun(after several hit) the swap space reduced to > nearly > 15MB.so i have a feeling that the Jrun is not releasing the memory > correctly. > > Is there any know memory issue in Jrun 3.0? > FYI,we have said the heap size as 512MB for Jrun. > > Thanks in advance. > > -- > Cheers, > rathna > > === > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff > JSP-INTEREST". > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST > DIGEST". > Some relevant FAQs on JSP/Servlets can be found at: > > http://java.sun.com/products/jsp/faq.html > http://www.esperanto.org.nz/jsp/jspfaq.html > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets > > === > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". > Some relevant FAQs on JSP/Servlets can be found at: > > http://java.sun.com/products/jsp/faq.html > http://www.esperanto.org.nz/jsp/jspfaq.html > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets -- Cheers, rathna ø¤°`°¤ø,¸¸¸,ø¤°`°¤ø,¸¸»«¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø P Rathinavel Sr.Systems Engineer - eCommerce Division Wipro Technologies Electronic City Bangalore 561229, India Tel : 8520420/416/424/408 Extn : 1322 E-mail: [EMAIL PROTECTED] www.wipro.com Living on earth may be costly,but it includes a free annual trip around the sun!! ø¤°`°¤ø,¸¸¸,ø¤°`°¤ø,¸¸»«¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
Re: Garbage collection issue - URGENT
Celeste, I wanted to understand that if that is the case then should i explicitly run the garbage collector or set all the references to null in all the jsp's? how would i identify the references which would be occupying the memory?? i am using iplanet web server. it would be same that also i supp.. piyush. - Original Message -- Celeste Haseltine <[EMAIL PROTECTED]> wrote: To:[EMAIL PROTECTED] From:Celeste Haseltine <[EMAIL PROTECTED]> Date:Thu, 3 May 2001 09:46:22 -0500 Subject:Re: Garbage collection issue - URGENT Rathna, Please double check what I am about to say on the Allaire developer web site, but I think that you have a misunderstanding of how a JSP complier/interpreter works, which is what JRUN is. In Java, you do a have garbage collection, such that when an object is no longer being "referenced" by anything else, the garbage collector comes in behind the scene and deallocates memory for you. But that is NOT how JRUN server works. It is a JSP interpreter/complier, and as such, when you "hit" a JSP page, that page is compiled into a servlet, and is then stored in memory. It remains in memory UNTIL you either restart you server, or change the JSP(at which time it is re-compiled). To my knowledge, JRUN server NEVER deallocates memory related to the JSP's or the servelets. Because of this, you sometimes get bizarre behavior when you change your JSP's often enough WITHOUT stopping and restarting the JRUN server during the development phase. That is one reason why I always stop and restart my JRUN server when I change either a JSP or a Servlet. I want to make sure that the previous copy has been "wiped" out of memory. Please note that this is NOT how your Java Objects/Beans are handled. The "references" to those objects and beans are deallocated by the JVM. Remember, the JVM is NOT compiling/interpreting your JSP or servelets, it is JRUN. Again, make sure that I am correct on this by posting to the Allaire developers web site/discussion group for JRUN 3.0. Good luck!!! Celeste -Original Message- From: A mailing list about Java Server Pages specification and reference [mailto:[EMAIL PROTECTED]]On Behalf Of Rathna Sent: Thursday, May 03, 2001 8:01 AM To: [EMAIL PROTECTED] Subject: Garbage collection issue - URGENT Hi all, I wonder is there any garbage collection problem in Jrun 3.0 version. we are using JDK 1.2.2 in jrun 3.0 version on solarix box. In the long run the application becomes very slow.we have 1GB of swap space and after running the jrun(after several hit) the swap space reduced to nearly 15MB.so i have a feeling that the Jrun is not releasing the memory correctly. Is there any know memory issue in Jrun 3.0? FYI,we have said the heap size as 512MB for Jrun. Thanks in advance. -- Cheers, rathna === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets _ Chat with your friends as soon as they come online. Get Rediff Bol at http://bol.rediff.com === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
Re: garbage collection
I am having similar problems, We are using Websphere App Server to server JSP's, System spec is a Pentium 2 500, with 550mb ram We started with the default of 16 mb, but soon found that we had the jsp failing, or timing out, after increasing the jvm heap memory to 64mb this then allowed the server time to discard the memory, this sounds very much like your problem. Many Thanks John === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
Re: garbage collection
From: "Kathy Wargo" <[EMAIL PROTECTED]> > we are developing a java application using servlet but after a few runs the application slows down. We noticed that this happens once the JVM's heap size reaches 16M. I would assume the garbage collection would be invoked and clear up the heap but this does not seem to be happening. We have tried to use finalize() methods and system.gc() also in the objects that are being created so that the garbage collector can free up the memory but nothing seems to be bringing the heap size down. Even leaving the computer idle for some time does not seem to be freeing up the resources. Any clues? You should analyze the app with some memory monitoring tool (NuMega's, etc.) Garbage collection cannot dispose objects if you have contention bugs (i.e., failing to eliminate all references to objects you don't need anymore). And maybe there's no problem at all; you should expect memory usage to increase and reach a higher plateau after a few runs, because the servlet engine will load servlet classes, set up thread and connection pools, maybe cache static content, and god knows what else. Server-side architectures are optimized for speed rather than memory usage; 16Mb is a rather small tiny heap, and unless you're running on extremely tight hardware or using a very old JVM, a heap that small shouldn't have any impact on performance. === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
Re: Garbage collection
You may also being holding references to objects that you thought you had released. An object will not be garbage collected if there are any live references to it. In Java you can't have traditional memory leaks, but you can have unintentional object retention. Caching systems and event notifications registrations are two common places where this can happen. Code walk throughs and the use a heap analysis tool can help. I believe that you can get a heap analysis tool, called HAT, from Sun's Java web site. Carles Reisman Jason wrote: > > That is correct. System.gc() will attempt to wake up the garbage > collection thread, but doesn't guarantee that it will run at that > instant. > However, you're missing the real problem: if you are getting to the > point that you may need to force a garbage collection you should > either (a) manage the number of objects that you're creating, or (b) > limit the size of your objects. Doing either may help with your > problem. > jR > > Taylor Gautier > <[EMAIL PROTECTED]>To: > Sent by: A mailing list about Java [EMAIL PROTECTED] > Server Pages specification and cc: > reference Subject:Re: > <[EMAIL PROTECTED]> Garbage collection > > 11/04/99 02:26 PM > Please respond to Taylor Gautier > > That doesn't FORCE garbage collection. Just suggests that if the GC > would > like to run, it can. > > -tg > - Original Message - > From: Pedro Teixeira <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, November 04, 1999 10:51 AM > Subject: Re: Garbage collection > > > Tao Kang wrote: > > > > > No. You cannot force garbage collection. > > > > No? What about java.lang.System.gc() ? > > > > -- > > > > # > > Pedro Teixeira > > USD > > Link<- > > > > Tao Kang wrote: > > > > No. You cannot force garbage collection. However, you can make an > > object to become 'subject to' > > garbage collection by making it 'unreachable.' (assigning the > reference > > varaible to null, for example) > > > > Because the garbage collector runs asynchronously to your program as > a > > separate thread, you cannot > > predict when it will execute, which unreachable objects it will > reclaim, > > and when it will reclaim those > > objects. > > > > Tae > > > > > === > > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff > JSP-INTEREST". > > FAQs on JSP can be found at: > > http://java.sun.com/products/jsp/faq.html > > http://www.esperanto.org.nz/jsp/jspfaq.html > > > > === > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff > JSP-INTEREST". > FAQs on JSP can be found at: > http://java.sun.com/products/jsp/faq.html > http://www.esperanto.org.nz/jsp/jspfaq.html === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". FAQs on JSP can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html
Re: Garbage collection
That is correct. System.gc() will attempt to wake up the garbage collection thread, but doesn't guarantee that it will run at that instant. However, you're missing the real problem: if you are getting to the point that you may need to force a garbage collection you should either (a) manage the number of objects that you're creating, or (b) limit the size of your objects. Doing either may help with your problem. jR Taylor Gautier <[EMAIL PROTECTED]> Sent by: A mailing list about Java Server Pages specification and reference <[EMAIL PROTECTED]> 11/04/99 02:26 PM Please respond to Taylor Gautier To: [EMAIL PROTECTED] cc: Subject: Re: Garbage collection That doesn't FORCE garbage collection. Just suggests that if the GC would like to run, it can. -tg - Original Message - From: Pedro Teixeira <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, November 04, 1999 10:51 AM Subject: Re: Garbage collection > Tao Kang wrote: > > > No. You cannot force garbage collection. > > No? What about java.lang.System.gc() ? > > -- > > # > Pedro Teixeira > USD > Link<- > > Tao Kang wrote: > > No. You cannot force garbage collection. However, you can make an > object to become 'subject to' > garbage collection by making it 'unreachable.' (assigning the reference > varaible to null, for example) > > Because the garbage collector runs asynchronously to your program as a > separate thread, you cannot > predict when it will execute, which unreachable objects it will reclaim, > and when it will reclaim those > objects. > > Tae > > === > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". > FAQs on JSP can be found at: > http://java.sun.com/products/jsp/faq.html > http://www.esperanto.org.nz/jsp/jspfaq.html > === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". FAQs on JSP can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html
Re: Garbage collection
If implemented correctly the destroy() method can at most cleanly forget all references so as to make them garbage collectable. It doesn't call garbage collection. System.gc() also does not necessarily run the garbage collection right there when called. This call only tells the garbage man "Hey come by when you get a chance". from JDK doc: When control returns from the method call, the Java Virtual Machine has made a best effort to reclaim space from all discarded objects. nothing is guaranteed. dave. Campbell wrote: > (more of a java q, but seems fitting...) Is there a way > to force garbage collection, such as with delete in > C++? Phil -- David Mossakowski [EMAIL PROTECTED] Programmer 212.310.7275 Instinet Corporation "I don't sit idly by, I'm planning a big surprise" === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". FAQs on JSP can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html
Re: Garbage collection
Actual, in Java the System.gc() is merely a suggestion. Garbage collection will still only happen when "the time is right". The destroy() method can be used to free up resources, but garbage collection does not necessarily occur at that time. Again the VM is in control of when GC actually occurs. Us mere mortals can merely make requests. ;^) Dan > -- > From: Reisman Jason[SMTP:[EMAIL PROTECTED]] > Reply To: [EMAIL PROTECTED] > Sent: Thursday, November 04, 1999 9:11 AM > To: [EMAIL PROTECTED] > Subject: Re: Garbage collection > > > Yes: System.gc(); > > > > > Campbell <[EMAIL PROTECTED]> > Sent by: A mailing list about Java Server Pages specification and > reference <[EMAIL PROTECTED]> > > 11/04/99 10:20 AM > Please respond to Campbell > > To:[EMAIL PROTECTED] > cc: > Subject:Garbage collection > > > (more of a java q, but seems fitting...) > > Is there a way to force garbage collection, such as with delete in C++? > > Phil > > > === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". FAQs on JSP can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html
Re: Garbage collection
Tao Kang wrote: > No. You cannot force garbage collection. No? What about java.lang.System.gc() ? -- # Pedro Teixeira USD Link<- Tao Kang wrote: No. You cannot force garbage collection. However, you can make an object to become 'subject to' garbage collection by making it 'unreachable.' (assigning the reference varaible to null, for example) Because the garbage collector runs asynchronously to your program as a separate thread, you cannot predict when it will execute, which unreachable objects it will reclaim, and when it will reclaim those objects. Tae === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". FAQs on JSP can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html
Re: Garbage collection
The Good News: This code will repeatedly run the garbage collector until it actually collects the garbage, overcoming the "best effort" nature of System.gc(). The Bad News: In a multi-threaded environment, this thread might well loop forever, as the (native Sun jdk) gc won't actually throw anything out unless it runs to completion (according to a source from JavaOne), and anything that contends with the gc will halt it and it will wait to start all over again. Additionally, one might mention that creation of new objects (again, multi-threaded) might outpace the gc, and thus it might loop unnecessarily in a situation where there is no garbage to collect (e.g., a bunch of objects get allocated by thread2 while thread1 is calling the gc() in the loop. this is pretty likely because the gc runs in the idle thread (under WinNT) and has the lowest possible priority, in order to avoid contention with application threads). Even if this code doesn't hang you up entirely, it will definitely kill your performance, unless you're in a single-threaded system. I have heard that HotSpot implements an incremental garbage collection algorithm. The gc is shrouded in mystery, and dealing with it is something of a black art. I'd be interested in hearing from anyone at Sun (or anywhere else that has implemented a JVM) who has actually worked on the implementation of the gc. This is, of course, totally off-topic to our JSP discussion, so if you'd like to conduct this via direct e-mail, that would be fine. -bml David Orkin wrote: > try this code: > > Runtime rt = Runtime.getRuntime( ); > long isFree = rt.freeMemory( ); > long wasFree; > do { >wasFree = isFree; >rt.gc( ); >isFree = rt.freeMemory( ); > } > while( isFree > wasFree ); > rt.runFinalization( ); > > === > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". > FAQs on JSP can be found at: > http://java.sun.com/products/jsp/faq.html > http://www.esperanto.org.nz/jsp/jspfaq.html -- _ Brian M. Long RandomWalk Computing, Inc.[EMAIL PROTECTED] 'Apollo was astonished / Dionysus thought me mad' -Hemispheres, 14:52 __ === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". FAQs on JSP can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html
Re: Garbage collection
That doesn't FORCE garbage collection. Just suggests that if the GC would like to run, it can. -tg - Original Message - From: Pedro Teixeira <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, November 04, 1999 10:51 AM Subject: Re: Garbage collection > Tao Kang wrote: > > > No. You cannot force garbage collection. > > No? What about java.lang.System.gc() ? > > -- > > # > Pedro Teixeira > USD > Link<- > > Tao Kang wrote: > > No. You cannot force garbage collection. However, you can make an > object to become 'subject to' > garbage collection by making it 'unreachable.' (assigning the reference > varaible to null, for example) > > Because the garbage collector runs asynchronously to your program as a > separate thread, you cannot > predict when it will execute, which unreachable objects it will reclaim, > and when it will reclaim those > objects. > > Tae > > === > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". > FAQs on JSP can be found at: > http://java.sun.com/products/jsp/faq.html > http://www.esperanto.org.nz/jsp/jspfaq.html > === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". FAQs on JSP can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html
Re: Garbage collection
try this code: Runtime rt = Runtime.getRuntime( ); long isFree = rt.freeMemory( ); long wasFree; do { wasFree = isFree; rt.gc( ); isFree = rt.freeMemory( ); } while( isFree > wasFree ); rt.runFinalization( ); === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". FAQs on JSP can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html
Re: Garbage collection
Yes: System.gc(); Campbell <[EMAIL PROTECTED]> Sent by: A mailing list about Java Server Pages specification and reference <[EMAIL PROTECTED]> 11/04/99 10:20 AM Please respond to Campbell To: [EMAIL PROTECTED] cc: Subject: Garbage collection (more of a java q, but seems fitting...) Is there a way to force garbage collection, such as with delete in C++? Phil
Re: Garbage collection
hi campbell, in java u have the destroy() method which when called will reclaim the resources held by the object on which the method was invoked. ex: if u call this method on a applet the thread gets killed. regards saravana kumar > -- > From: Campbell[SMTP:[EMAIL PROTECTED]] > Reply To: Campbell > Sent: Thursday, November 04, 1999 9:50 PM > To: [EMAIL PROTECTED] > Subject: Garbage collection > > (more of a java q, but seems fitting...) > > Is there a way to force garbage collection, such as with delete in C++? > > Phil > === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". FAQs on JSP can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html
Re: Garbage collection
No. You cannot force garbage collection. However, you can make an object to become 'subject to' garbage collection by making it 'unreachable.' (assigning the reference varaible to null, for example) Because the garbage collector runs asynchronously to your program as a separate thread, you cannot predict when it will execute, which unreachable objects it will reclaim, and when it will reclaim those objects. Tae - Original Message - From: Campbell To: [EMAIL PROTECTED] Sent: Thursday, November 04, 1999 8:20 AM Subject: Garbage collection (more of a java q, but seems fitting...) Is there a way to force garbage collection, such as with delete in C++? Phil
Re: Garbage collection
From the JDK 1.1.7B javadocs for java.lang.System. gc public static void gc() Runs the garbage collector. Calling the gc method suggests that the Java Virtual Machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call, the Java Virtual Machine has made a best effort to reclaim space from all unused objects. See Also: gc runFinalization public static void runFinalization() Runs the finalization methods of any objects pending finalization. Calling this method suggests that the Java Virtual Machine expend effort toward running the finalize methods of objects that have been found to be discarded but whose finalize methods have not yet been run. When control returns from the method call, the Java Virtual Machine has made a best effort to complete all outstanding finalizations. See Also: runFinalization runFinalizersOnExit public static void runFinalizersOnExit(boolean value) Enable or disable finalization on exit; doing so specifies that the finalizers of all objects that have finalizers that have not yet been automatically invoked are to be run before the Java runtime exits. By default, finalization on exit is disabled. See Also: exit, gc -Original Message-From: A mailing list about Java Server Pages specification and reference [mailto:[EMAIL PROTECTED]]On Behalf Of CampbellSent: Thursday, November 04, 1999 10:21 AMTo: [EMAIL PROTECTED]Subject: Garbage collection (more of a java q, but seems fitting...) Is there a way to force garbage collection, such as with delete in C++? Phil