21 * questions.
22 */
23
24 package MyPackage;
25
26 import java.util.ArrayList;
27 import java.util.List;
28
29 /** API for handling the underlying heap sampling monitoring system. */
30 public class HeapMonitor {
31 static {
32 try {
33 System.loadLibrary("HeapMonitor");
34 } catch (UnsatisfiedLinkError ule) {
35 System.err.println("Could not load HeapMonitor library");
36 System.err.println("java.library.path: " + System.getProperty("java.library.path"));
37 throw ule;
38 }
39 }
40
41 private static int arrays[][];
42
43 /** Enable heap monitoring sampling given a rate and maximum garbage to keep in memory. */
44 public native static void enableSampling(int rate, int maximumGarbage);
45
46 /** Enable heap monitoring sampling given a rate. */
47 public static void enableSampling(int rate) {
48 enableSampling(rate, 200);
49 }
50
51 /** Enable heap monitoring sampling with default values for rate and maximum garbage. */
52 public static void enableSampling() {
53 enableSampling(1 << 19);
54 }
55
56 public native static void disableSampling();
57 public native static boolean areSamplingStatisticsZero();
58 public native static boolean statsHaveExpectedNumberSamples(int expected, int percentError);
59
60 /** Do the frames provided exist in live, recent garbage, and frequent garbage. */
61 public native static boolean framesExistEverywhere(Frame[] frames);
|
21 * questions.
22 */
23
24 package MyPackage;
25
26 import java.util.ArrayList;
27 import java.util.List;
28
29 /** API for handling the underlying heap sampling monitoring system. */
30 public class HeapMonitor {
31 static {
32 try {
33 System.loadLibrary("HeapMonitor");
34 } catch (UnsatisfiedLinkError ule) {
35 System.err.println("Could not load HeapMonitor library");
36 System.err.println("java.library.path: " + System.getProperty("java.library.path"));
37 throw ule;
38 }
39 }
40
41 private static volatile int arrays[][];
42
43 /** Enable heap monitoring sampling given a rate and maximum garbage to keep in memory. */
44 public native static void enableSampling(int rate, int maximumGarbage);
45
46 /** Enable heap monitoring sampling given a rate. */
47 public static void enableSampling(int rate) {
48 enableSampling(rate, 200);
49 }
50
51 /** Enable heap monitoring sampling with default values for rate and maximum garbage. */
52 public static void enableSampling() {
53 enableSampling(1 << 19);
54 }
55
56 public native static void disableSampling();
57 public native static boolean areSamplingStatisticsZero();
58 public native static boolean statsHaveExpectedNumberSamples(int expected, int percentError);
59
60 /** Do the frames provided exist in live, recent garbage, and frequent garbage. */
61 public native static boolean framesExistEverywhere(Frame[] frames);
|