-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Vicky,
On 5/23/2011 9:42 AM, vicky b wrote: > I have done analysis on static references and found a interesting > point al;so i find a difference in behaviour in tomcat 6 andtomcat 7 Um, okay. > I created a class (TestStatic) which has a static reference to VO(java bean) > in my servlet i declared TestStatic as member variable and initialized it > there Let's see that mess of language above shown in code, shall we? > public class VO { > String name; > public String getName() { > return name;} > public void setName(String name) { > this.name = name;} > } No code for a servlet called "TestStatic" was included. Assuming you aren't being very careful to document a problem that relies on very detailed information, let's move-on with the code you *did* post. Your servlet has a reference to TestEnum, not VO, but let's just keep rollin'. I've removed some of the code that doesn't affect usage of these classes, etc. > *public* *class* TestEnum { > *private* BeanName name; > *private* *static* VO vo = *new* VO(); > }} > > *public* *class* Leak *extends* HttpServlet { > TestEnum a = *new* TestEnum(); > } So, after undeploy, TestEnum.vo remains reachable? It's possible that you have another leak that is causing the WebappClassLoader to remain in memory, which will prevent your webapp's java.lang.Class objects from being collected by the GC. In that case, the static members will also remain in memory. As suggested in another thread, you might want to look at a memory profiler to see what is keeping your webapp's classes in memory. Yes, things have changed from Tomcat 6 to Tomcat 7, but none of them affect the JVM's GC algorithm(s). Recent Tomcat 6 and all Tomcat 7 releases include some speculative leak-prevention strategies that can help reduce ClassLoader-pinning leaks that are out of your webapp's control, so it's possible that's affecting your observations. > so what can be concluded static references are never garbage collected ? or > even objects holding static references are not GC'ed. Something tells me it's more complicated than that. > In tomcat static refrence are getting garbage collected but in weblogic it > is not can any body help If that's the case, I suspect Tomcat's leak-prevention code is helping you out. You're welcome to read the code: it's quite straightforward. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk3azOEACgkQ9CaO5/Lv0PAxbgCeOrmCQlN/t1tgsTjHIeM1LtOQ Z0QAmwZzzfAPqzRbEqpp7R6DDW41XLKC =ZWjs -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org