Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update README.md

  • Loading branch information...
commit 6433caad636d95ace0173f31015a4a0c9a923677 1 parent 89c1f94
Norbert Hu authored
Showing with 17 additions and 22 deletions.
  1. +17 −22 README.md
View
39 README.md
@@ -17,39 +17,36 @@ The built jar will be in 'target/'.
## Implementing the HeapAudit hook
Currently, two recorders are provided with HeapAudit:
- - [HeapActivity](https://github.com/foursquare/heapaudit/blob/master/src/main/java/com/foursquare/heapaudit/HeapActivity.java) prints each heap allocation to stdout
- - [HeapQuantile](https://github.com/foursquare/heapaudit/blob/master/src/main/java/com/foursquare/heapaudit/HeapQuantile.java) accumulates allocations and dumps out summary at the end
-Both of the above inherit from the base class HeapRecorder. Additional recording
-behavior can be extended by implementing [HeapRecorder](https://github.com/foursquare/heapaudit/blob/master/src/main/java/com/foursquare/heapaudit/HeapRecorder.java).
-
- For instance:
+- [HeapActivity](https://github.com/foursquare/heapaudit/blob/master/src/main/java/com/foursquare/heapaudit/HeapActivity.java) prints each heap allocation to stdout
+- [HeapQuantile](https://github.com/foursquare/heapaudit/blob/master/src/main/java/com/foursquare/heapaudit/HeapQuantile.java) accumulates allocations and dumps out summary at the end
- class MyRecorder extends HeapRecorder {
+Both of the above inherit from the base class HeapRecorder. Additional recording
+behavior can be extended by implementing the record method in [HeapRecorder](https://github.com/foursquare/heapaudit/blob/master/src/main/java/com/foursquare/heapaudit/HeapRecorder.java).
- @Override public void record(String name,
- int count,
- long size) {
+ class MyRecorder extends HeapRecorder {
- System.out.println("Allocated " + name +
- "[" + count + "] " + size + " bytes");
+ @Override public void record(String name,
+ int count,
+ long size) {
- }
+ System.out.println("Allocated " + name +
+ "[" + count + "] " + size + " bytes");
}
+ }
+
Recording starts when it is registered and stops when it is unregistered. Each
recorder can be registered globally across all threads or local to the current.
- For instance:
-
- MyRecorder r = new MyRecorder();
+ MyRecorder r = new MyRecorder();
- HeapRecorder.register(r, false);
+ HeapRecorder.register(r, false);
- MyObject o = new MyObject();
+ MyObject o = new MyObject();
- HeapRecorder.unregister(r, false);
+ HeapRecorder.unregister(r, false);
## Launching the HeapAudit java agent
@@ -61,9 +58,7 @@ Additional options can be passed to HeapAudit to customize which classes and/or
methods are not to be instrumented for recording allocations. For additional
information on how to specify the options, see [HeapSettings.java](https://github.com/foursquare/heapaudit/blob/master/src/main/java/com/foursquare/heapaudit/HeapSettings.java).
- For instance:
-
- $ java -javaagent:heapaudit.jar="-Ccom/foursquare/test/.+" MyTest
+ $ java -javaagent:heapaudit.jar="-Ccom/foursquare/test/.+" MyTest
## Dependencies
Please sign in to comment.
Something went wrong with that request. Please try again.