(original) (raw)
On 8/12/11 1:08 PM, suraj puvvada wrote:"I use RedefineClasses() API extensively. Wanted to know what is the impact redefining a class has on Perm Gen ? Are the older versions of a redefined class retained in memory forever ?"
If there is a more appropriate forum to post appreciate if you can let me know.
ThanksSuraj
You've found the right forum.
Short answer: older versions of redefined methods are only kept
around as long as a thread is executing that method.
Longer answer: When RedefineClasses() replaces a target class, it
keeps weak references to various parts (methods and the constant
pool come to mind) of the original class for internal book keeping
reasons. As threads finish executing the obsolete or old methods,
they become GC'able. That doesn't mean they are GC'ed right away,
but they will be eventually.
Dan