google/allocation-instrumenter
소개
바이트코드를 재작성해 메모리 할당 지점을 계측하는 Java 에이전트
프로그래밍 언어 및 런타임측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalThe Allocation Instrumenter is a Java agent written using the java.lang.instrument API and ASM. Each allocation in your Java program is instrumented; a user-defined callback is invoked on each allocation.
How to get it
The latest release is available from Maven Central as:
<dependency>
<groupId>com.google.code.java-allocation-instrumenter</groupId>
<artifactId>java-allocation-instrumenter</artifactId>
<version>3.3.4</version>
</dependency>
Basic usage
In order to write your own allocation tracking code, you have to implement the Sampler interface
and pass an instance of that to AllocationRecorder.addSampler():
AllocationRecorder.addSampler(new Sampler() {
public void sampleAllocation(int count, String desc, Object newObj, long size) {
System.out.println("I just allocated the object " + newObj +
" of type " + desc + " whose size is " + size);
if (count != -1) { System.out.println("It's an array of size " + count); }
}
});
You can also use the allocation instrumenter to instrument constructors of particular classes.
You do this by instantiating a ConstructorCallback and passing it to
ConstructorInstrumenter.instrumentClass():
try {
ConstructorInstrumenter.instrumentClass(
Thread.class, new ConstructorCallback<Thread>() {
@Override public void sample(Thread t) {
System.out.println("Instantiating a thread");
}
});
} catch (UnmodifiableClassException e) {
System.out.println("Class cannot be modified");
}
For more information on how to get or use the allocation instrumenter, see Getting Started.
관련 프로젝트 살펴보기
불러오는 중…