001/**
002 * Copyright The Apache Software Foundation
003 *
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *     http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020package org.apache.hadoop.hbase.io;
021
022import org.apache.yetus.audience.InterfaceAudience;
023
024/**
025 * Implementations can be asked for an estimate of their size in bytes.
026 * <p>
027 * Useful for sizing caches.  Its a given that implementation approximations
028 * do not account for 32 vs 64 bit nor for different VM implementations.
029 * <p>
030 * An Object's size is determined by the non-static data members in it,
031 * as well as the fixed {@link Object} overhead.
032 * <p>
033 * For example:
034 * <pre>
035 * public class SampleObject implements HeapSize {
036 *
037 *   int [] numbers;
038 *   int x;
039 * }
040 * </pre>
041 */
042@InterfaceAudience.Private
043public interface HeapSize {
044  /**
045   * @return Approximate 'exclusive deep size' of implementing object.  Includes
046   * count of payload and hosting object sizings.
047  */
048  long heapSize();
049}