1 /* |
1 /* |
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
25 * @test |
25 * @test |
26 * @summary Test consistency of NMT by leaking a few select allocations of the Test type and then verify visibility with jcmd |
26 * @summary Test consistency of NMT by leaking a few select allocations of the Test type and then verify visibility with jcmd |
27 * @key nmt jcmd |
27 * @key nmt jcmd |
28 * @library /testlibrary /testlibrary/whitebox |
28 * @library /testlibrary /testlibrary/whitebox |
29 * @build MallocTestType |
29 * @build MallocTestType |
|
30 * @ignore |
30 * @run main ClassFileInstaller sun.hotspot.WhiteBox |
31 * @run main ClassFileInstaller sun.hotspot.WhiteBox |
31 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocTestType |
32 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:NativeMemoryTracking=detail MallocTestType |
32 */ |
33 */ |
33 |
34 |
34 import com.oracle.java.testlibrary.*; |
35 import com.oracle.java.testlibrary.*; |
49 long memAlloc2 = wb.NMTMalloc(256 * 1024); |
50 long memAlloc2 = wb.NMTMalloc(256 * 1024); |
50 wb.NMTFree(memAlloc3); |
51 wb.NMTFree(memAlloc3); |
51 long memAlloc1 = wb.NMTMalloc(512 * 1024); |
52 long memAlloc1 = wb.NMTMalloc(512 * 1024); |
52 wb.NMTFree(memAlloc2); |
53 wb.NMTFree(memAlloc2); |
53 |
54 |
54 // Use WB API to ensure that all data has been merged before we continue |
|
55 if (!wb.NMTWaitForDataMerge()) { |
|
56 throw new Exception("Call to WB API NMTWaitForDataMerge() failed"); |
|
57 } |
|
58 |
|
59 // Run 'jcmd <pid> VM.native_memory summary' |
55 // Run 'jcmd <pid> VM.native_memory summary' |
60 pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); |
56 pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "summary"}); |
61 output = new OutputAnalyzer(pb.start()); |
57 output = new OutputAnalyzer(pb.start()); |
62 output.shouldContain("Test (reserved=512KB, committed=512KB)"); |
58 output.shouldContain("Test (reserved=512KB, committed=512KB)"); |
63 |
59 |
64 // Free the memory allocated by NMTAllocTest |
60 // Free the memory allocated by NMTAllocTest |
65 wb.NMTFree(memAlloc1); |
61 wb.NMTFree(memAlloc1); |
66 |
62 |
67 // Use WB API to ensure that all data has been merged before we continue |
|
68 if (!wb.NMTWaitForDataMerge()) { |
|
69 throw new Exception("Call to WB API NMTWaitForDataMerge() failed"); |
|
70 } |
|
71 output = new OutputAnalyzer(pb.start()); |
63 output = new OutputAnalyzer(pb.start()); |
72 output.shouldNotContain("Test (reserved="); |
64 output.shouldNotContain("Test (reserved="); |
73 } |
65 } |
74 } |
66 } |