summaryrefslogtreecommitdiffstats
path: root/src/main/javassist/ClassPool.java
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2004-08-19 14:04:32 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2004-08-19 14:04:32 +0000
commit8c82477b4172ed0db9e5d866a0dba22ae20eb23f (patch)
tree413e976fd906df977b3ebf383f4eddf9372de84e /src/main/javassist/ClassPool.java
parent7fd8dd68388f6e910b1e0f54df363a84481d0809 (diff)
downloadjavassist-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.java10
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;
+ }
}
/**