1cfd74d65d832137e20e193c960802afba73b5d38sm/* 23c1e67e433728684b5f228c5d4f3e5b1457bb271sm * Copyright (C) 2010 The Android Open Source Project 3cfd74d65d832137e20e193c960802afba73b5d38sm * 4cfd74d65d832137e20e193c960802afba73b5d38sm * Licensed under the Apache License, Version 2.0 (the "License"); 5cfd74d65d832137e20e193c960802afba73b5d38sm * you may not use this file except in compliance with the License. 6cfd74d65d832137e20e193c960802afba73b5d38sm * You may obtain a copy of the License at 7cfd74d65d832137e20e193c960802afba73b5d38sm * 8cfd74d65d832137e20e193c960802afba73b5d38sm * http://www.apache.org/licenses/LICENSE-2.0 9cfd74d65d832137e20e193c960802afba73b5d38sm * 10cfd74d65d832137e20e193c960802afba73b5d38sm * Unless required by applicable law or agreed to in writing, software 11cfd74d65d832137e20e193c960802afba73b5d38sm * distributed under the License is distributed on an "AS IS" BASIS, 12cfd74d65d832137e20e193c960802afba73b5d38sm * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13cfd74d65d832137e20e193c960802afba73b5d38sm * See the License for the specific language governing permissions and 14cfd74d65d832137e20e193c960802afba73b5d38sm * limitations under the License. 15cfd74d65d832137e20e193c960802afba73b5d38sm */ 16cfd74d65d832137e20e193c960802afba73b5d38sm 17cfd74d65d832137e20e193c960802afba73b5d38smpackage com.replica.replicaisland; 18cfd74d65d832137e20e193c960802afba73b5d38sm 19cfd74d65d832137e20e193c960802afba73b5d38sm/** 20cfd74d65d832137e20e193c960802afba73b5d38sm * AllocationGuard is a utility class for tracking down memory leaks. It implements a 21cfd74d65d832137e20e193c960802afba73b5d38sm * "checkpoint" memory scheme. After the static sGuardActive flag has been set, any further 22cfd74d65d832137e20e193c960802afba73b5d38sm * allocation of AllocationGuard or its derivatives will cause an error log entry. Note 23cfd74d65d832137e20e193c960802afba73b5d38sm * that AllocationGuard requires all of its derivatives to call super() in their constructor. 24cfd74d65d832137e20e193c960802afba73b5d38sm */ 25cfd74d65d832137e20e193c960802afba73b5d38smpublic class AllocationGuard { 26cfd74d65d832137e20e193c960802afba73b5d38sm public static boolean sGuardActive = false; 27cfd74d65d832137e20e193c960802afba73b5d38sm public AllocationGuard() { 28cfd74d65d832137e20e193c960802afba73b5d38sm if (sGuardActive) { 29cfd74d65d832137e20e193c960802afba73b5d38sm // An allocation has occurred while the guard is active! Report it. 30cfd74d65d832137e20e193c960802afba73b5d38sm DebugLog.e("AllocGuard", "An allocation of type " + this.getClass().getName() 31cfd74d65d832137e20e193c960802afba73b5d38sm + " occurred while the AllocGuard is active."); 32cfd74d65d832137e20e193c960802afba73b5d38sm 33cfd74d65d832137e20e193c960802afba73b5d38sm 34cfd74d65d832137e20e193c960802afba73b5d38sm } 35cfd74d65d832137e20e193c960802afba73b5d38sm } 36cfd74d65d832137e20e193c960802afba73b5d38sm} 37