class UnsafeMemoryBudget {

	void releaseMemory(@Nonnegative long size) {
		if (size == 0) {
			return;
		}
		boolean released = false;
		long currentAvailableMemorySize = 0L;
		while (!released && totalMemorySize >= (currentAvailableMemorySize = availableMemorySize.get()) + size) {
			released = availableMemorySize
				.compareAndSet(currentAvailableMemorySize, currentAvailableMemorySize + size);
		}
		if (!released) {
			throw new IllegalStateException(String.format(
				"Trying to release more managed memory (%d bytes) than has been allocated (%d bytes), the total size is %d bytes",
				size,
				currentAvailableMemorySize,
				totalMemorySize));
		}
	}

	  UnsafeMemoryBudget(long totalMemorySize, int verifyEmptyWaitGcMaxSleeps);

}