public static long usedMemory(final Runtime runtime) {
        long totalBegin;
        long totalEnd;
        long used;
        do {
            totalBegin = runtime.totalMemory();
            used = totalBegin - runtime.freeMemory();
            totalEnd = runtime.totalMemory();
        } while (totalBegin != totalEnd);

        return used;
    }
@Test
    public void testUsedMemory() {
        Assert.assertTrue(JVMUtil.usedMemory(Runtime.getRuntime()) > 0);
    }