Skip to content

Commit

Permalink
Update packages
Browse files Browse the repository at this point in the history
  • Loading branch information
danielshaya committed Oct 8, 2015
1 parent 01649e1 commit 1bf1763
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
@@ -1,14 +1,14 @@
# ByteWatcher
# org.octtech.bw.ByteWatcher

ByteWatcher allows you to programmatically monitor the number of bytes allocated by your program.
org.octtech.bw.ByteWatcher allows you to programmatically monitor the number of bytes allocated by your program.

It is especially useful for embedding into regression tests when allocation is a critical factor. This will typically be the case for low latency applications.

You can monitor all the threads in your application and are alerted when an exceeded number of bytes are allocated.

##Getting Started:

If you want the latest release binary to add to your project just go to the [latest release in GitHub](https://github.com/danielshaya/ByteWatcher/releases) and download the jar file.
If you want the latest release binary to add to your project just go to the [latest release in GitHub](https://github.com/danielshaya/org.octtech.bw.ByteWatcher/releases) and download the jar file.

Alternatively you can download the source code from GitHub and build using Maven.

Expand All @@ -19,7 +19,7 @@ To be honest, given the amount of code, even copy and paste should work fine.
This code will print out a warning message if more than 1MB of data has been allocated by a single thread:
```java
long limit = 1<<20;
ByteWatcher by = new ByteWatcher();
org.octtech.bw.ByteWatcher by = new org.octtech.bw.ByteWatcher();
bw.onByteWatch((t, size) ->
System.out.printf("%s exceeded limit: %d using: %d%n",
t.getName(), limit, size)
Expand All @@ -41,19 +41,19 @@ You can also be alerted when a thread is created or destroyed:

This code will print out all the threads when a new thread is created
```java
ByteWatcher bw = new ByteWatcher();
org.octtech.bw.ByteWatcher bw = new org.octtech.bw.ByteWatcher();
bw.onThreadCreated(System.out::println);
```

This code will print out all the threads when a thread is destroyed
```java
ByteWatcher bw = new ByteWatcher();
org.octtech.bw.ByteWatcher bw = new org.octtech.bw.ByteWatcher();
bw.onThreadDied(System.out::println);
```

The class has a useful utility method which allows you to see all the allocation at any point in time
```java
ByteWatcher bw = new ByteWatcher();
org.octtech.bw.ByteWatcher bw = new org.octtech.bw.ByteWatcher();
bw.printAllAllocations();
```
Example output:
Expand All @@ -68,7 +68,7 @@ Finalizer allocated 0

BytesWatcher will by default sample the threads every 500 milliseconds. This can be overridden with the vm option `SamplingIntervalMillis`.

Each sampling costs normally 336 bytes. This is accounted for in the calculation so is not attributed to your program. It has been noted that on occasion this number can vary slightly. Best efforts have been made to minimise the impact this might have on a client program by running a calibration routine when ByteWatcher starts. However unless you are quite literally looking for zero allocation the effect will be negligible. Even in a zero allocation environment it shouldn't have an impact and can be completely mitigated by running your program with -Xcomp.
Each sampling costs normally 336 bytes. This is accounted for in the calculation so is not attributed to your program. It has been noted that on occasion this number can vary slightly. Best efforts have been made to minimise the impact this might have on a client program by running a calibration routine when org.octtech.bw.ByteWatcher starts. However unless you are quite literally looking for zero allocation the effect will be negligible. Even in a zero allocation environment it shouldn't have an impact and can be completely mitigated by running your program with -Xcomp.



Expand Down
@@ -1,3 +1,4 @@
package org.octtech.bw;
/*
* Copyright (C) 2015 Daniel Shaya and Heinz Max Kabutz
*
Expand Down
@@ -1,3 +1,4 @@
package org.octtech.bw;
/*
* Copyright (C) 2015 Daniel Shaya and Heinz Max Kabutz
*
Expand Down
@@ -1,3 +1,4 @@
package org.octtech.bw;
/*
* Copyright (C) 2015 Daniel Shaya and Heinz Max Kabutz
*
Expand Down
@@ -1,3 +1,4 @@
package org.octtech.bw;
/*
* Copyright (C) 2015 Daniel Shaya and Heinz Max Kabutz
*
Expand All @@ -17,6 +18,7 @@
*/

import org.junit.*;
import org.octtech.bw.ByteWatcherRegressionTestHelper;

public class ByteWatcherRegressionTestHelperTest {

Expand Down
@@ -1,3 +1,4 @@
package org.octtech.bw;
/*
* Copyright (C) 2015 Daniel Shaya and Heinz Max Kabutz
*
Expand All @@ -17,6 +18,7 @@
*/

import org.junit.*;
import org.octtech.bw.ByteWatcherSingleThread;

import java.util.*;

Expand Down
@@ -1,3 +1,4 @@
package org.octtech.bw;
/*
* Copyright (C) 2015 Daniel Shaya and Heinz Max Kabutz
*
Expand All @@ -17,6 +18,7 @@
*/

import org.junit.*;
import org.octtech.bw.ByteWatcher;

import java.util.*;

Expand Down

0 comments on commit 1bf1763

Please sign in to comment.