se.softhouse.common.testlib.MemoryTester Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common-test Show documentation
Show all versions of common-test Show documentation
Reusable classes to use from tests.
/* Copyright 2013 Jonatan Jönsson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package se.softhouse.common.testlib;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.fest.assertions.Assertions.assertThat;
import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.ThreadSafe;
import com.google.common.testing.GcFinalization;
/**
* Helps to test for memory leaks
*/
@Immutable
public final class MemoryTester
{
private MemoryTester()
{
}
/**
* A simple {@link PhantomReference} that can be used to assert that all references to it is
* gone.
*/
@ThreadSafe
public static final class FinalizationAwareObject extends PhantomReference © 2015 - 2025 Weber Informatics LLC | Privacy Policy