1 Reply Latest reply on Feb 3, 2010 8:45 AM by Arvind K

    Strategy for classpool = null clearing

    Paul Keeble Newbie

      In the tutorial one of the noted problems is the memory usage climb with creating a lot of CtClass's etc that are all stored in the ClassPool. I am having trouble combining that advice with a javaagent implementation.

      The problem is really the order you see classes in and knowing when its safe to clear the pool. For instance say I have the following two classes:

      class Account {
      Class SavingsAccount extends Account {

      The javaagent will receive first the Account class, followed by the SavingsAccount. If you clear the pool after the Account class then SavingsAccount will see an a non enhanced class (which I can't do as I am adding constructors which the subclass will call).

      So the question is really what is the usual approach to this? So far I have tried the following:

      - Clearing every X times called, fails for obvious reasons
      - Clearing at the beginning of the program, fails because not all classes are necessarily loaded at that point

      I need something that some how mind reads the future calls! Any ideas?