diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2004-08-19 14:04:32 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2004-08-19 14:04:32 +0000 |
commit | 8c82477b4172ed0db9e5d866a0dba22ae20eb23f (patch) | |
tree | 413e976fd906df977b3ebf383f4eddf9372de84e /src/main/javassist/ClassPool.java | |
parent | 7fd8dd68388f6e910b1e0f54df363a84481d0809 (diff) | |
download | javassist-8c82477b4172ed0db9e5d866a0dba22ae20eb23f.tar.gz javassist-8c82477b4172ed0db9e5d866a0dba22ae20eb23f.zip |
implemented pruning
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@125 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/ClassPool.java')
-rw-r--r-- | src/main/javassist/ClassPool.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main/javassist/ClassPool.java b/src/main/javassist/ClassPool.java index 6ddcf31d..a75dec94 100644 --- a/src/main/javassist/ClassPool.java +++ b/src/main/javassist/ClassPool.java @@ -37,6 +37,8 @@ import java.util.Hashtable; * of memory. To avoid this, a <code>ClassPool</code> object * should be recreated, for example, every hundred classes processed. * Note that <code>getDefault()</code> is a singleton factory. + * Otherwise, <code>detach()</code> in <code>CtClass</code> should be used + * to avoid huge memory consumption. * * <p><b><code>ClassPool</code> hierarchy:</b> * @@ -75,6 +77,8 @@ public class ClassPool { */ private Hashtable cflow = null; // should be synchronous. + private static final int INIT_HASH_SIZE = 191; + /** * Creates a root class pool. No parent class pool is specified. * @@ -91,7 +95,7 @@ public class ClassPool { * @see javassist.ClassPool#getDefault() */ public ClassPool(ClassPool parent) { - this.classes = new Hashtable(); + this.classes = new Hashtable(INIT_HASH_SIZE); this.source = new ClassPoolTail(); this.parent = parent; if (parent == null) { @@ -289,8 +293,10 @@ public class ClassPool { if (clazz == null) throw new NotFoundException(classname); - else + else { + clazz.incGetCounter(); return clazz; + } } /** |