提交 635c9e13 authored 作者: Thomas Mueller's avatar Thomas Mueller

avoid out of memory

上级 88c6f379
...@@ -78,7 +78,11 @@ public class StringCache { ...@@ -78,7 +78,11 @@ public class StringCache {
String[] cache = (String[]) softCache.get(); String[] cache = (String[]) softCache.get();
int hash = s.hashCode(); int hash = s.hashCode();
if (cache == null) { if (cache == null) {
cache = new String[SysProperties.OBJECT_CACHE_SIZE]; try {
cache = new String[SysProperties.OBJECT_CACHE_SIZE];
} catch (OutOfMemoryError e) {
return s;
}
softCache = new SoftReference(cache); softCache = new SoftReference(cache);
} }
int index = hash & (SysProperties.OBJECT_CACHE_SIZE - 1); int index = hash & (SysProperties.OBJECT_CACHE_SIZE - 1);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论