>
> >I have a static counter attribute, and I do not want to see it gc'ed.
> >Am I missing something ?
> >
> >Jean-Luc
>
> If it's static it won't be GC'd.
>
I may misunderstand what you're talking about here, but
static members of classes are gc'd like any other object in Java
when it becomes unreachable. For a static member to become
unreachable, its class must have become unreachable. If class gc
is disabled, no class ever becomes unreachable, hence no static
members are ever gc'd.
For this reason, I don't think using a static member variable as a persistent
counter makes sense by itself. While it will survive multiple requests,
it won't survive class reloading. Class reloading creates a new instance of
that static member variable. If you disable class gc, the old instance
will be floating garbage, hence the memory leak.
I think what you'll need is some mechanism to write out your counter to
disk when the class is gc --- this could be a finalizer --- and some
mechanism to read it back in when your class gets initialized.
This could be done in a <clinit> method (as in static { ... });
- Godmar
----------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html/>
Problems?: [EMAIL PROTECTED]