Skip to content

Instantly share code, notes, and snippets.

@danielshaya
Created August 14, 2015 14:09
Show Gist options
  • Save danielshaya/e202dadd1bc29ef90af1 to your computer and use it in GitHub Desktop.
Save danielshaya/e202dadd1bc29ef90af1 to your computer and use it in GitHub Desktop.
@Test
public void allocationRegressionTest(){
long limit = 1<<20;
ByteWatcher bw = new ByteWatcher();
bw.onByteWatch((t, size) ->
//Allocation breached - cause an assertion to happen
assertTrue(String.format("%s exceeded limit: %d using: %d%n",
t.getName(), limit, size), false)
, limit);
//Run your program here
//.....
//.....
//If the bytes limit is breached ByteWatcher will call back the method
//onByteWatch and an assertion will be triggered.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment