All Downloads are FREE. Search and download functionalities are using the official Maven repository.

at.spardat.xma.mdl.MemoryEstimator Maven / Gradle / Ivy

There is a newer version: 6.0.2
Show newest version
/*******************************************************************************
 * Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH .
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     s IT Solutions AT Spardat GmbH - initial API and implementation
 *******************************************************************************/

// @(#) $Id: MemoryEstimator.java 2089 2007-11-28 13:56:13Z s3460 $
package at.spardat.xma.mdl;

/**
 * Provides some utility method to estimate the memory consumption of java objects.
 * 
 * @author YSD, 01.06.2003 10:21:52
 */
public class MemoryEstimator {

    /**
     * Returns the number of bytes an java objects consumes that has numInstances
     * instance variables. Thats the size of the object itself, without complex
     * instance variables.
     */
    public static int sizeOfObject (int numInstances) {
        return 8 + 4 * numInstances;
    }
    
    /**
     * Returns the number of bytes a String consumes if it is not shared with other
     * Strings.
     */
    public static int sizeOf (String s) {
        return 38 + 2 * s.length();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy