>>> Carmine Lucarelli <[EMAIL PROTECTED]> 02-Feb-00 6:30:14 PM >>>

>Hi all, trying to avoid possible memory leaks.  When I instantiate
objects in my
>servlet's service methods, will the references to those objects
vanish when the
>doGet or doPost finishes, making them eligible for garbage
collection?

Yes. With Java 1.1 GC was quite slow (because the GC sat on a lower
priority thread) - with Java 2 it's fast enough for you to not worry
about it overtly.

It's still a big performance problem though... many people don't
realise that one easy way to deal with peformance in servlets is to
lower the pre-request object creation.


>Also, is there a method that would return how many objects
>are currently in existence?

No, not that I know of anyway. You would have to go down to the JVM
level for this... you could probably do it by getting Kaffe or Japhar
(JVMs that have free source code available) and hacking it but that's
a lot of trouble for something you can normally do by counting.

It is possible to profile Java classes, an operation that produces
statistics on how much memory is used and by what objects... that
might be what you want. Check the java.sun.com site (developer
connection is free and has lots of intersting things about this sort
of stuff).



Nic Ferrier

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to