मेरे पास एक प्रोग्राम है जो अंततः OutOfMemory
उत्पन्न करना चाहिए तो जावा डंप उत्पन्न करें। कार्यक्रम कोड है:जब आउटऑफमेमरी
public class VeryLargeObject implements Serializable {
public static final int SIZE = 1 << 12;
public String tag;
public int[][] bigOne = new int[SIZE][SIZE];
{
// Initialize bigOne
for(int i = 0; i < SIZE ; ++i) {
for(int j = 0; j < SIZE; ++j) {
bigOne[i][j] = (int) (Math.random() * 100);
}
}
}
public VeryLargeObject(String tag) {
this.tag = tag;
}
public static void main(String args[]) {
VeryLargeObject[] vla = new VeryLargeObject[1 << 12];
for(int i = 0; i < Integer.MAX_VALUE; ++i) {
vla[i] = new VeryLargeObject("aa");
}
}
}
मैं निम्नलिखित मानकों के साथ कार्यक्रम चलाने:
java VeryLargeObject -Xms1024m -Xmx1024m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="D:\workspace"
कार्यक्रम OutOfMemory के साथ विफल हो लेकिन कोई डंप फ़ाइल उत्पन्न होता है। क्या आपको कोई विचार है क्यों?
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at VeryLargeObject.<init>(VeryLargeObject.java:14)
at VeryLargeObject.main(VeryLargeObject.java:32)
नहीं क्या आप कहने का मतलब था कि ढेर फ़ाइल उत्पन्न नहीं हुई? और यह नहीं होना चाहिए -XX: -HeapDumpOnOutOfMemoryError के बजाय त्रुटि: + HeapDumpOnOutOfMemoryError (+ संकेत देखें) – CoolBeans
> प्रोग्राम OutOfMemory के साथ विफल रहता है लेकिन फ़ाइल उत्पन्न होने पर अब डंप करें। - क्या यह एक टाइपो है? - क्या आपका मतलब ** अब ** या ** नहीं ** है? – Ralph