@ThreadSafe public class Accountant extends Object implements AutoCloseable
Modifier and Type | Class and Description |
---|---|
static class |
Accountant.AllocationOutcome
Describes the type of outcome that occurred when trying to account for allocation of memory.
|
Modifier and Type | Field and Description |
---|---|
static boolean |
ALLOW_LENIENCY |
static String |
ALLOW_LENIENT_ALLOCATION |
static int |
GRACE_MARGIN |
static int |
MAX_GRACE |
protected Accountant |
parent
The parent allocator
|
protected long |
reservation
The amount of memory reserved for this allocator.
|
Constructor and Description |
---|
Accountant(Accountant parent,
long reservation,
long maxAllocation) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close this Accountant.
|
void |
forceLenient()
Force lenient allocation.
|
long |
getAllocatedMemory()
Return the current amount of allocated memory that this Accountant is managing accounting for.
|
long |
getLimit()
Return the current limit of this Accountant.
|
long |
getPeakMemoryAllocation()
The peak memory allocated by this Accountant.
|
boolean |
isOverLimit() |
void |
releaseBytes(long size) |
boolean |
setLenient()
Request lenient allocations: allows exceeding the allocation limit
by the configured grace amount.
|
void |
setLimit(long newLimit)
Set the maximum amount of memory that can be allocated in the this Accountant before failing an allocation.
|
public static final String ALLOW_LENIENT_ALLOCATION
public static final int GRACE_MARGIN
public static final int MAX_GRACE
public static final boolean ALLOW_LENIENCY
protected final Accountant parent
protected final long reservation
public Accountant(Accountant parent, long reservation, long maxAllocation)
public boolean setLenient()
public void forceLenient()
public void releaseBytes(long size)
public void setLimit(long newLimit)
newLimit
- The limit in bytes.public boolean isOverLimit()
public void close()
close
in interface AutoCloseable
public long getLimit()
public long getAllocatedMemory()
public long getPeakMemoryAllocation()
Copyright © 1970 The Apache Software Foundation. All rights reserved.