public class Memory extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
long |
alloc
已分配的
|
int |
gcCount
full-GC次数
|
int |
gcTime
full-GC消耗时间(秒)
|
protected long |
m_Critical
内存空间严重不足界线
|
protected GarbageCollectorMXBean |
m_gc
full-GC相关的收集器(通常是旧生代)
|
protected NameItem |
m_Level
最后计算的内存状态
|
protected Condition |
m_LevelEvent
状态事件
|
protected Lock |
m_Lock
等待锁
|
long |
max
上限
|
static NameItem |
MEMORY_CRITICAL
内存严重不足,能扔的都扔了吧
|
static NameItem |
MEMORY_IDEL
可用内存很多
|
static NameItem |
MEMORY_LOW
内存低,尽量去除缓存
|
static NameItem |
MEMORY_NORMAL
内存使用情况正常
|
static NameItem |
MEMORY_SUSPEND
内存严重不足,能扔的都扔了吧
|
long |
usable
(最大)可用的
|
| 构造器和说明 |
|---|
Memory() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected NameItem |
calcSate()
统计内存使用状态 MEMORY_xxx
|
boolean |
checkLevel(NameItem level)
检查内存是否达到指定的状态以上(MEMORY_SUSPEND->MEMORY_CRITICAL->MEMORY_LOW->
MEMORY_NORMAL ->MEMORY_IDEL)
|
long |
getAlloc()
已分配的
|
int |
getGcCount()
full-GC次数
|
int |
getGcTime()
full-GC消耗时间(秒)
|
NameItem |
getLevel() |
long |
getMax() |
static int |
getRefreshPeriod()
默认内存使用状态刷新周期(毫秒)
|
long |
getUsable()
(最大)可用的
|
int |
refresh()
刷新内存使用状态
|
void |
setCritical(long bytes)
设定内存空间严重不足界线
|
String |
toString() |
StringBuilder |
toString(StringBuilder sb) |
int |
waitFor(NameItem level,
int timeoutMs)
等待内存达到指定的状态以上(MEMORY_SUSPEND->MEMORY_CRITICAL->MEMORY_LOW->MEMORY_NORMAL
->MEMORY_IDEL)
|
public static final NameItem MEMORY_IDEL
public static final NameItem MEMORY_NORMAL
public static final NameItem MEMORY_LOW
public static final NameItem MEMORY_CRITICAL
public static final NameItem MEMORY_SUSPEND
public long max
public long usable
public long alloc
public int gcCount
public int gcTime
protected NameItem m_Level
protected final Lock m_Lock
protected final Condition m_LevelEvent
protected long m_Critical
protected GarbageCollectorMXBean m_gc
public static int getRefreshPeriod()
public int refresh()
public long getMax()
public long getUsable()
public long getAlloc()
public int getGcCount()
public int getGcTime()
public NameItem getLevel()
public boolean checkLevel(NameItem level)
level - 要检查的内存状态public int waitFor(NameItem level, int timeoutMs) throws InterruptedIOException
level - 要等的内存状态timeoutMs - 等待超时值(毫秒),=0则永远等待InterruptedIOException - 中断时抛出public void setCritical(long bytes)
bytes - 不足界线(单位字)protected NameItem calcSate()
public StringBuilder toString(StringBuilder sb)
Copyright © 2021. All rights reserved.