Skip to content

Apache Lucene open-source search software

better memory estimate

Wolfgang Hoschek34e917af0351
diff --git a/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java b/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
index 33d656380c5..e5e4ffe829e 100644
--- a/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
+++ b/contrib/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
@@ -478,11 +478,15 @@ public class MemoryIndex {
}
private static boolean is64BitVM() {
- int bits = Integer.getInteger("sun.arch.data.model", 0).intValue();
- if (bits != 0) return bits == 64;
-
- // fallback if sun.arch.data.model isn't available
- return System.getProperty("java.vm.name").toLowerCase().indexOf("64") >= 0;
+ try {
+ int bits = Integer.getInteger("sun.arch.data.model", 0).intValue();
+ if (bits != 0) return bits == 64;
+
+ // fallback if sun.arch.data.model isn't available
+ return System.getProperty("java.vm.name").toLowerCase().indexOf("64") >= 0;
+ } catch (Throwable t) {
+ return false; // better safe than sorry (applets, security managers, etc.) ...
+ }
}
private int numPositions(ArrayIntList positions) {