Update of /cvsroot/nice/Nice/src/gnu/bytecode
In directory sc8-pr-cvs1:/tmp/cvs-serv4508/src/gnu/bytecode
Modified Files:
Type.java ClassFileInput.java
Log Message:
Delete ClassTypes from the cache, to avoid memory usage from groing
for multiple compilations in the same JVM.
Index: Type.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/gnu/bytecode/Type.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** Type.java 23 Nov 2003 19:15:15 -0000 1.16
--- Type.java 27 Nov 2003 00:21:20 -0000 1.17
***************
*** 28,33 ****
}
// Maps java.lang.Class to corresponding Type.
! private static java.util.Hashtable mapClassToType;
/** Maps Java type name (e.g. "java.lang.String[]") to corresponding Type. */
--- 28,51 ----
}
+ public static void free(java.util.Map t)
+ {
+ for (java.util.Iterator e = t.entrySet().iterator(); e.hasNext();)
+ {
+ java.util.Map.Entry k = (java.util.Map.Entry) e.next();
+ if (((Type) k.getValue()).collectable)
+ e.remove();
+ }
+ }
+
+ public boolean collectable;
+
+ public static void reset()
+ {
+ mapClassToType.clear();
+ free(mapNameToType);
+ }
+
// Maps java.lang.Class to corresponding Type.
! private static java.util.Map mapClassToType;
/** Maps Java type name (e.g. "java.lang.String[]") to corresponding Type. */
***************
*** 113,122 ****
mapNameToType.put(name, type);
}
!
/** Register that the Type for class is type. */
public static void registerTypeForClass(Class clas, Type type)
{
if (mapClassToType == null)
! mapClassToType = new java.util.Hashtable(100);
mapClassToType.put(clas, type);
type.reflectClass = clas;
--- 131,140 ----
mapNameToType.put(name, type);
}
!
/** Register that the Type for class is type. */
public static void registerTypeForClass(Class clas, Type type)
{
if (mapClassToType == null)
! mapClassToType = new java.util.HashMap(100);
mapClassToType.put(clas, type);
type.reflectClass = clas;
***************
*** 179,182 ****
--- 197,201 ----
type.reflectClass = reflectClass;
registerTypeForClass(reflectClass, type);
+ type.collectable = true;
return type;
}
Index: ClassFileInput.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/gnu/bytecode/ClassFileInput.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ClassFileInput.java 29 Oct 2003 12:42:41 -0000 1.4
--- ClassFileInput.java 27 Nov 2003 00:21:20 -0000 1.5
***************
*** 67,71 ****
*/
if (ctype.constants != null)
! ctype = new ClassType(name);
// Read the class from the file.
--- 67,74 ----
*/
if (ctype.constants != null)
! {
! ctype = new ClassType(name);
! ctype.collectable = true;
! }
// Read the class from the file.
|