Hi Mark!

I don't think so. When you "set a bean equal to null", you just erase a
reference to it. Any other references left around would make it linger
in memory, and there might be a few. Are you talking about EJBs?

Anyway, if you set to null the only existing reference, you'll have to
wait for the next gc cycle. If you call System.gc() explicitly, you're
forcing this cycle and the object might go away.

Un saludo,

Alex.

"Jurrius, Mark" wrote:
> 
> Correct me if I'm wrong.  If for instance I want a bean removed knowing that
> System.gc() does not happen immediately, would setting the bean equal to
> null force the bean to be removed from memory right away and not have to
> rely on the garbage collection to eventually take place?
> 
> Mark
> 
> -----Original Message-----
> From:   William Kaufman [mailto:[EMAIL PROTECTED]]
> Sent:   Thursday, May 03, 2001 10:07 AM
> To:     '[EMAIL PROTECTED]'
> Subject:        RE: Memory usage
> 
> > That your finalize method is called, doesn't mean that
> > the garbage collector has released your objects. The
> > only way to be shure that this happens, is to explicitly
> > run System.gc().
> 
> Even that's not sufficient: it just suggests to the VM that
> garbage-collecting might be a good idea right now.  Any actual garbage
> collection would take place later, in another thread.
> 
> And, even when it does happen, that doesn't mean all the memory will
> necessarily be released to the OS: the VM will hold on to some so that it
> won't need to go back to the OS on the next allocation.
> 
> You might want to get a memory profiler (like JProbe) and see where the
> memory is going.  At the very least, try doing something like,
> 
>         Runtime rt = Runtime.getRuntime();
>         System.err.println("Free="+rt.freeMemory()+",
> total="+rt.totalMemory());
> 
> often, to see how much memory is actually in use, and how much is just
> allocated from the OS.
> 
>                                                             -- Bill K.
> 
> > -----Original Message-----
> > From: Ralph Einfeldt [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, May 03, 2001 5:51 AM
> > To: '[EMAIL PROTECTED]'
> > Subject: AW: Memory usage
> >
> >
> > That your finalize method is called, doesn't mean that
> > the garbage collector has released your objects. The
> > only way to be shure that this happens, is to explicitly
> > run System.gc(). Otherwise it's up to the VM when it will
> > free the memory. (Sun's JDK per default only releases
> > memory if otherwise an OutOfMemoryError would occur, so
> > unless you reach this border the VM will constanly grow)
> >
> > See also the options for the JVM:
> >   -verbose:gc (Any VM)
> >   -Xincgc (Sun SDK 1.3.*)
> >   -Xms (Sun + IBM)
> >   -Xmx (Sun + IBM)
> >
> > -----Ursprüngliche Nachricht-----
> > Von: Garry De Toffoli [mailto:[EMAIL PROTECTED]]
> > Gesendet: Donnerstag, 3. Mai 2001 14:34
> > An: [EMAIL PROTECTED]
> > Betreff: Memory usage
> >
> > <snip/>
> > I have in trouble with the memory usage with Tomcat 3.21, WinNt 2000
> > and Jdk 1.3 of Sun. the problem is that any operation does
> > not release
> > the memory occuped; to control the memory usage I use the
> > Task Manager;
> > when Tomcat start, the memory used from the process Java is of 9608 K;
> > when I request a Jsp page that has an error, like a variable
> > not declared,
> > the memory used is 11868K; if I wait for 1 ay also, this
> > value does not
> > change, so the memory used is not released,
> >
> > running a correct Jsp page, the memory used increase, and this is not
> > released yet;
> > I have written a log on the finalize method of my class, and this is
> > called, so the garbage collector release all my object.
> >
> > This behavoir is normal?
> > Probably changing the version of Tomcat this problem may be corrected.
> > <snip/>
> >

Reply via email to