View | Details | Raw Unified | Return to bug 106202
Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/JavaModelCache.java (-9 / +10 lines)
Lines 19-30 Link Here
19
 * The cache of java elements to their respective info.
19
 * The cache of java elements to their respective info.
20
 */
20
 */
21
public class JavaModelCache {
21
public class JavaModelCache {
22
	public static final int BASE_VALUE = 20;
23
	public static final int DEFAULT_PROJECT_SIZE = 5;  // average 25552 bytes per project.
22
	public static final int DEFAULT_PROJECT_SIZE = 5;  // average 25552 bytes per project.
24
	public static final int DEFAULT_ROOT_SIZE = BASE_VALUE*10; // average 2590 bytes per root -> maximum size : 25900*BASE_VALUE bytes
23
	public static final int DEFAULT_ROOT_SIZE = 50; // average 2590 bytes per root -> maximum size : 25900*BASE_VALUE bytes
25
	public static final int DEFAULT_PKG_SIZE = BASE_VALUE*100; // average 1782 bytes per pkg -> maximum size : 178200*BASE_VALUE bytes
24
	public static final int DEFAULT_PKG_SIZE = 500; // average 1782 bytes per pkg -> maximum size : 178200*BASE_VALUE bytes
26
	public static final int DEFAULT_OPENABLE_SIZE = BASE_VALUE*100; // average 6629 bytes per openable (includes children) -> maximum size : 662900*BASE_VALUE bytes
25
	public static final int DEFAULT_OPENABLE_SIZE = 500; // average 6629 bytes per openable (includes children) -> maximum size : 662900*BASE_VALUE bytes
27
	public static final int DEFAULT_CHILDREN_SIZE = BASE_VALUE*100*20; // average 20 children per openable
26
	public static final int DEFAULT_CHILDREN_SIZE = 500*20; // average 20 children per openable
28
	
27
	
29
	/**
28
	/**
30
	 * Active Java Model Info
29
	 * Active Java Model Info
Lines 57-67 Link Here
57
	protected Map childrenCache;
56
	protected Map childrenCache;
58
	
57
	
59
public JavaModelCache() {
58
public JavaModelCache() {
59
	// set the size of the caches in function of the maximum amount of memory available
60
	double ratio =  Runtime.getRuntime().maxMemory() / 64000000; // 64000000 is the base memory for most JVM
60
	this.projectCache = new HashMap(DEFAULT_PROJECT_SIZE); // NB: Don't use a LRUCache for projects as they are constantly reopened (e.g. during delta processing)
61
	this.projectCache = new HashMap(DEFAULT_PROJECT_SIZE); // NB: Don't use a LRUCache for projects as they are constantly reopened (e.g. during delta processing)
61
	this.rootCache = new ElementCache(DEFAULT_ROOT_SIZE);
62
	this.rootCache = new ElementCache((int) (DEFAULT_ROOT_SIZE * ratio));
62
	this.pkgCache = new ElementCache(DEFAULT_PKG_SIZE);
63
	this.pkgCache = new ElementCache((int) (DEFAULT_PKG_SIZE * ratio));
63
	this.openableCache = new ElementCache(DEFAULT_OPENABLE_SIZE);
64
	this.openableCache = new ElementCache((int) (DEFAULT_OPENABLE_SIZE * ratio));
64
	this.childrenCache = new HashMap(DEFAULT_CHILDREN_SIZE);
65
	this.childrenCache = new HashMap((int) (DEFAULT_CHILDREN_SIZE * ratio));
65
}
66
}
66
67
67
/**
68
/**

Return to bug 106202