Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_hotspot
提交
d2e415fa
D
dragonwell8_hotspot
项目概览
openanolis
/
dragonwell8_hotspot
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_hotspot
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d2e415fa
编写于
3月 25, 2013
作者:
S
stefank
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
36f43da5
d4ee5a03
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
177 addition
and
12 deletion
+177
-12
src/share/vm/memory/metaspace.hpp
src/share/vm/memory/metaspace.hpp
+4
-4
src/share/vm/memory/universe.cpp
src/share/vm/memory/universe.cpp
+1
-0
src/share/vm/runtime/arguments.cpp
src/share/vm/runtime/arguments.cpp
+0
-5
src/share/vm/services/memoryManager.cpp
src/share/vm/services/memoryManager.cpp
+4
-0
src/share/vm/services/memoryManager.hpp
src/share/vm/services/memoryManager.hpp
+10
-0
src/share/vm/services/memoryPool.cpp
src/share/vm/services/memoryPool.cpp
+34
-0
src/share/vm/services/memoryPool.hpp
src/share/vm/services/memoryPool.hpp
+26
-0
src/share/vm/services/memoryService.cpp
src/share/vm/services/memoryService.cpp
+18
-3
src/share/vm/services/memoryService.hpp
src/share/vm/services/memoryService.hpp
+5
-0
test/gc/metaspace/TestMetaspaceMemoryPools.java
test/gc/metaspace/TestMetaspaceMemoryPools.java
+75
-0
未找到文件。
src/share/vm/memory/metaspace.hpp
浏览文件 @
d2e415fa
...
...
@@ -157,16 +157,16 @@ class Metaspace : public CHeapObj<mtClass> {
class
MetaspaceAux
:
AllStatic
{
static
size_t
free_chunks_total
(
Metaspace
::
MetadataType
mdtype
);
static
size_t
free_chunks_total_in_bytes
(
Metaspace
::
MetadataType
mdtype
);
public:
// Statistics for class space and data space in metaspace.
static
size_t
used_in_bytes
(
Metaspace
::
MetadataType
mdtype
);
static
size_t
free_in_bytes
(
Metaspace
::
MetadataType
mdtype
);
static
size_t
capacity_in_bytes
(
Metaspace
::
MetadataType
mdtype
);
static
size_t
reserved_in_bytes
(
Metaspace
::
MetadataType
mdtype
);
static
size_t
free_chunks_total
(
Metaspace
::
MetadataType
mdtype
);
static
size_t
free_chunks_total_in_bytes
(
Metaspace
::
MetadataType
mdtype
);
public:
// Total of space allocated to metadata in all Metaspaces
static
size_t
used_in_bytes
()
{
return
used_in_bytes
(
Metaspace
::
ClassType
)
+
...
...
src/share/vm/memory/universe.cpp
浏览文件 @
d2e415fa
...
...
@@ -1108,6 +1108,7 @@ bool universe_post_init() {
// Initialize performance counters for metaspaces
MetaspaceCounters
::
initialize_performance_counters
();
MemoryService
::
add_metaspace_memory_pools
();
GC_locker
::
unlock
();
// allow gc after bootstrapping
...
...
src/share/vm/runtime/arguments.cpp
浏览文件 @
d2e415fa
...
...
@@ -1169,7 +1169,6 @@ void Arguments::set_cms_and_parnew_gc_flags() {
set_parnew_gc_flags
();
}
// MaxHeapSize is aligned down in collectorPolicy
size_t
max_heap
=
align_size_down
(
MaxHeapSize
,
CardTableRS
::
ct_max_alignment_constraint
());
...
...
@@ -1207,10 +1206,6 @@ void Arguments::set_cms_and_parnew_gc_flags() {
}
// Code along this path potentially sets NewSize and OldSize
assert
(
max_heap
>=
InitialHeapSize
,
"Error"
);
assert
(
max_heap
>=
NewSize
,
"Error"
);
if
(
PrintGCDetails
&&
Verbose
)
{
// Too early to use gclog_or_tty
tty
->
print_cr
(
"CMS set min_heap_size: "
SIZE_FORMAT
...
...
src/share/vm/services/memoryManager.cpp
浏览文件 @
d2e415fa
...
...
@@ -61,6 +61,10 @@ MemoryManager* MemoryManager::get_code_cache_memory_manager() {
return
(
MemoryManager
*
)
new
CodeCacheMemoryManager
();
}
MemoryManager
*
MemoryManager
::
get_metaspace_memory_manager
()
{
return
(
MemoryManager
*
)
new
MetaspaceMemoryManager
();
}
GCMemoryManager
*
MemoryManager
::
get_copy_memory_manager
()
{
return
(
GCMemoryManager
*
)
new
CopyMemoryManager
();
}
...
...
src/share/vm/services/memoryManager.hpp
浏览文件 @
d2e415fa
...
...
@@ -56,6 +56,7 @@ public:
enum
Name
{
Abstract
,
CodeCache
,
Metaspace
,
Copy
,
MarkSweepCompact
,
ParNew
,
...
...
@@ -88,6 +89,7 @@ public:
// Static factory methods to get a memory manager of a specific type
static
MemoryManager
*
get_code_cache_memory_manager
();
static
MemoryManager
*
get_metaspace_memory_manager
();
static
GCMemoryManager
*
get_copy_memory_manager
();
static
GCMemoryManager
*
get_msc_memory_manager
();
static
GCMemoryManager
*
get_parnew_memory_manager
();
...
...
@@ -108,6 +110,14 @@ public:
const
char
*
name
()
{
return
"CodeCacheManager"
;
}
};
class
MetaspaceMemoryManager
:
public
MemoryManager
{
public:
MetaspaceMemoryManager
()
:
MemoryManager
()
{}
MemoryManager
::
Name
kind
()
{
return
MemoryManager
::
Metaspace
;
}
const
char
*
name
()
{
return
"MetaspaceManager"
;
}
};
class
GCStatInfo
:
public
ResourceObj
{
private:
size_t
_index
;
...
...
src/share/vm/services/memoryPool.cpp
浏览文件 @
d2e415fa
...
...
@@ -26,12 +26,15 @@
#include "classfile/systemDictionary.hpp"
#include "classfile/vmSymbols.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/globals.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/javaCalls.hpp"
#include "runtime/os.hpp"
#include "services/lowMemoryDetector.hpp"
#include "services/management.hpp"
#include "services/memoryManager.hpp"
#include "services/memoryPool.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
MemoryPool
::
MemoryPool
(
const
char
*
name
,
...
...
@@ -256,3 +259,34 @@ MemoryUsage CodeHeapPool::get_memory_usage() {
return
MemoryUsage
(
initial_size
(),
used
,
committed
,
maxSize
);
}
MetaspacePoolBase
::
MetaspacePoolBase
(
const
char
*
name
,
Metaspace
::
MetadataType
md_type
,
size_t
max_size
)
:
_md_type
(
md_type
),
MemoryPool
(
name
,
NonHeap
,
MetaspaceAux
::
capacity_in_bytes
(
_md_type
),
max_size
,
true
,
false
)
{
}
size_t
MetaspacePoolBase
::
used_in_bytes
()
{
return
MetaspaceAux
::
used_in_bytes
(
_md_type
);
}
MemoryUsage
MetaspacePoolBase
::
get_memory_usage
()
{
size_t
used
=
MetaspaceAux
::
used_in_bytes
(
_md_type
);
size_t
committed
=
align_size_down_
(
MetaspaceAux
::
capacity_in_bytes
(
_md_type
),
os
::
vm_page_size
());
return
MemoryUsage
(
initial_size
(),
used
,
committed
,
max_size
());
}
ClassMetaspacePool
::
ClassMetaspacePool
()
:
MetaspacePoolBase
(
"Class Metaspace"
,
Metaspace
::
ClassType
,
calculate_max_size
())
{
}
size_t
ClassMetaspacePool
::
calculate_max_size
()
{
return
UseCompressedKlassPointers
?
ClassMetaspaceSize
:
_undefined_max_size
;
}
MetaspacePool
::
MetaspacePool
()
:
MetaspacePoolBase
(
"Metaspace"
,
Metaspace
::
NonClassType
,
calculate_max_size
())
{
}
size_t
MetaspacePool
::
calculate_max_size
()
{
return
FLAG_IS_CMDLINE
(
MaxMetaspaceSize
)
?
MaxMetaspaceSize
:
_undefined_max_size
;
}
src/share/vm/services/memoryPool.hpp
浏览文件 @
d2e415fa
...
...
@@ -28,6 +28,7 @@
#include "gc_implementation/shared/mutableSpace.hpp"
#include "memory/defNewGeneration.hpp"
#include "memory/heap.hpp"
#include "memory/metaspace.hpp"
#include "memory/space.hpp"
#include "services/memoryUsage.hpp"
#include "utilities/macros.hpp"
...
...
@@ -222,4 +223,29 @@ public:
size_t
used_in_bytes
()
{
return
_codeHeap
->
allocated_capacity
();
}
};
class
MetaspacePoolBase
:
public
MemoryPool
{
private:
Metaspace
::
MetadataType
_md_type
;
protected:
static
const
size_t
_undefined_max_size
=
(
size_t
)
-
1
;
public:
MetaspacePoolBase
(
const
char
*
name
,
Metaspace
::
MetadataType
md_type
,
size_t
max_size
);
MemoryUsage
get_memory_usage
();
size_t
used_in_bytes
();
};
class
ClassMetaspacePool
:
public
MetaspacePoolBase
{
private:
size_t
calculate_max_size
();
public:
ClassMetaspacePool
();
};
class
MetaspacePool
:
public
MetaspacePoolBase
{
private:
size_t
calculate_max_size
();
public:
MetaspacePool
();
};
#endif // SHARE_VM_SERVICES_MEMORYPOOL_HPP
src/share/vm/services/memoryService.cpp
浏览文件 @
d2e415fa
...
...
@@ -60,9 +60,11 @@ GrowableArray<MemoryPool*>* MemoryService::_pools_list =
GrowableArray
<
MemoryManager
*>*
MemoryService
::
_managers_list
=
new
(
ResourceObj
::
C_HEAP
,
mtInternal
)
GrowableArray
<
MemoryManager
*>
(
init_managers_list_size
,
true
);
GCMemoryManager
*
MemoryService
::
_minor_gc_manager
=
NULL
;
GCMemoryManager
*
MemoryService
::
_major_gc_manager
=
NULL
;
MemoryPool
*
MemoryService
::
_code_heap_pool
=
NULL
;
GCMemoryManager
*
MemoryService
::
_minor_gc_manager
=
NULL
;
GCMemoryManager
*
MemoryService
::
_major_gc_manager
=
NULL
;
MemoryPool
*
MemoryService
::
_code_heap_pool
=
NULL
;
MemoryPool
*
MemoryService
::
_metaspace_pool
=
NULL
;
MemoryPool
*
MemoryService
::
_class_metaspace_pool
=
NULL
;
class
GcThreadCountClosure
:
public
ThreadClosure
{
private:
...
...
@@ -399,6 +401,19 @@ void MemoryService::add_code_heap_memory_pool(CodeHeap* heap) {
_managers_list
->
append
(
mgr
);
}
void
MemoryService
::
add_metaspace_memory_pools
()
{
_metaspace_pool
=
new
MetaspacePool
();
_class_metaspace_pool
=
new
ClassMetaspacePool
();
MemoryManager
*
mgr
=
MemoryManager
::
get_metaspace_memory_manager
();
mgr
->
add_pool
(
_metaspace_pool
);
mgr
->
add_pool
(
_class_metaspace_pool
);
_pools_list
->
append
(
_metaspace_pool
);
_pools_list
->
append
(
_class_metaspace_pool
);
_managers_list
->
append
(
mgr
);
}
MemoryManager
*
MemoryService
::
get_memory_manager
(
instanceHandle
mh
)
{
for
(
int
i
=
0
;
i
<
_managers_list
->
length
();
i
++
)
{
MemoryManager
*
mgr
=
_managers_list
->
at
(
i
);
...
...
src/share/vm/services/memoryService.hpp
浏览文件 @
d2e415fa
...
...
@@ -73,6 +73,10 @@ private:
// Code heap memory pool
static
MemoryPool
*
_code_heap_pool
;
// Metaspace pools
static
MemoryPool
*
_metaspace_pool
;
static
MemoryPool
*
_class_metaspace_pool
;
static
void
add_generation_memory_pool
(
Generation
*
gen
,
MemoryManager
*
major_mgr
,
MemoryManager
*
minor_mgr
);
...
...
@@ -121,6 +125,7 @@ private:
public:
static
void
set_universe_heap
(
CollectedHeap
*
heap
);
static
void
add_code_heap_memory_pool
(
CodeHeap
*
heap
);
static
void
add_metaspace_memory_pools
();
static
MemoryPool
*
get_memory_pool
(
instanceHandle
pool
);
static
MemoryManager
*
get_memory_manager
(
instanceHandle
mgr
);
...
...
test/gc/metaspace/TestMetaspaceMemoryPools.java
0 → 100644
浏览文件 @
d2e415fa
import
java.util.List
;
import
java.lang.management.ManagementFactory
;
import
java.lang.management.MemoryManagerMXBean
;
import
java.lang.management.MemoryPoolMXBean
;
import
java.lang.management.MemoryUsage
;
/* @test TestMetaspaceMemoryPools
* @bug 8000754
* @summary Tests that two MemoryPoolMXBeans are created, one for metaspace and
* one for class metaspace, is created and that a MemoryManagerMXBean
* is created.
* @run main/othervm TestMetaspaceMemoryPools defined undefined
* @run main/othervm -XX:-UseCompressedKlassPointers TestMetaspaceMemoryPools undefined undefined
* @run main/othervm -XX:-UseCompressedKlassPointers -XX:MaxMetaspaceSize=60m TestMetaspaceMemoryPools undefined defined
*/
public
class
TestMetaspaceMemoryPools
{
public
static
void
main
(
String
[]
args
)
{
boolean
isClassMetaspaceMaxDefined
=
args
[
0
].
equals
(
"defined"
);
boolean
isMetaspaceMaxDefined
=
args
[
1
].
equals
(
"defined"
);
verifyThatMetaspaceMemoryManagerExists
();
verifyMemoryPool
(
getMemoryPool
(
"Class Metaspace"
),
isClassMetaspaceMaxDefined
);
verifyMemoryPool
(
getMemoryPool
(
"Metaspace"
),
isMetaspaceMaxDefined
);
}
private
static
void
verifyThatMetaspaceMemoryManagerExists
()
{
List
<
MemoryManagerMXBean
>
managers
=
ManagementFactory
.
getMemoryManagerMXBeans
();
for
(
MemoryManagerMXBean
manager
:
managers
)
{
if
(
manager
.
getName
().
equals
(
"MetaspaceManager"
))
{
return
;
}
}
throw
new
RuntimeException
(
"Expected to find a metaspace memory manager"
);
}
private
static
MemoryPoolMXBean
getMemoryPool
(
String
name
)
{
List
<
MemoryPoolMXBean
>
pools
=
ManagementFactory
.
getMemoryPoolMXBeans
();
for
(
MemoryPoolMXBean
pool
:
pools
)
{
if
(
pool
.
getName
().
equals
(
name
))
{
return
pool
;
}
}
throw
new
RuntimeException
(
"Expected to find a memory pool with name "
+
name
);
}
private
static
void
verifyMemoryPool
(
MemoryPoolMXBean
pool
,
boolean
isMaxDefined
)
{
MemoryUsage
mu
=
pool
.
getUsage
();
assertDefined
(
mu
.
getInit
(),
"init"
);
assertDefined
(
mu
.
getUsed
(),
"used"
);
assertDefined
(
mu
.
getCommitted
(),
"committed"
);
if
(
isMaxDefined
)
{
assertDefined
(
mu
.
getMax
(),
"max"
);
}
else
{
assertUndefined
(
mu
.
getMax
(),
"max"
);
}
}
private
static
void
assertDefined
(
long
value
,
String
name
)
{
assertTrue
(
value
!=
-
1
,
"Expected "
+
name
+
" to be defined"
);
}
private
static
void
assertUndefined
(
long
value
,
String
name
)
{
assertTrue
(
value
==
-
1
,
"Expected "
+
name
+
" to be undefined"
);
}
private
static
void
assertTrue
(
boolean
condition
,
String
msg
)
{
if
(!
condition
)
{
throw
new
RuntimeException
(
msg
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录