Show / Hide Table of Contents

    Class RamUsageEstimator

    Estimates the size (memory representation) of .NET objects.

    This is a Lucene.NET INTERNAL API, use at your own risk
    Inheritance
    System.Object
    RamUsageEstimator
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Lucene.Net.Util
    Assembly: Lucene.Net.dll
    Syntax
    public sealed class RamUsageEstimator

    Fields

    | Improve this Doc View Source

    NUM_BYTES_ARRAY_HEADER

    Number of bytes to represent an array header (no content, but with alignments).

    Declaration
    public static readonly int NUM_BYTES_ARRAY_HEADER
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    NUM_BYTES_BOOLEAN

    Declaration
    public const int NUM_BYTES_BOOLEAN = 1
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    NUM_BYTES_BYTE

    Declaration
    public const int NUM_BYTES_BYTE = 1
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    NUM_BYTES_CHAR

    Declaration
    public const int NUM_BYTES_CHAR = 2
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    NUM_BYTES_DOUBLE

    Declaration
    public const int NUM_BYTES_DOUBLE = 8
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    NUM_BYTES_INT16

    NOTE: This was NUM_BYTES_SHORT in Lucene

    Declaration
    public const int NUM_BYTES_INT16 = 2
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    NUM_BYTES_INT32

    NOTE: This was NUM_BYTES_INT in Lucene

    Declaration
    public const int NUM_BYTES_INT32 = 4
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    NUM_BYTES_INT64

    NOTE: This was NUM_BYTES_LONG in Lucene

    Declaration
    public const int NUM_BYTES_INT64 = 8
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    NUM_BYTES_OBJECT_ALIGNMENT

    A constant specifying the object alignment boundary inside the .NET runtime. Objects will always take a full multiple of this constant, possibly wasting some space.

    Declaration
    public static readonly int NUM_BYTES_OBJECT_ALIGNMENT
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    NUM_BYTES_OBJECT_HEADER

    Number of bytes to represent an object header (no fields, no alignments).

    Declaration
    public static readonly int NUM_BYTES_OBJECT_HEADER
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    NUM_BYTES_OBJECT_REF

    Number of bytes this .NET runtime uses to represent an object reference.

    Declaration
    public static readonly int NUM_BYTES_OBJECT_REF
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    NUM_BYTES_SINGLE

    NOTE: This was NUM_BYTES_FLOAT in Lucene

    Declaration
    public const int NUM_BYTES_SINGLE = 4
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    ONE_GB

    One gigabyte bytes.

    Declaration
    public static readonly long ONE_GB
    Field Value
    Type Description
    System.Int64
    | Improve this Doc View Source

    ONE_KB

    One kilobyte bytes.

    Declaration
    public static readonly long ONE_KB
    Field Value
    Type Description
    System.Int64
    | Improve this Doc View Source

    ONE_MB

    One megabyte bytes.

    Declaration
    public static readonly long ONE_MB
    Field Value
    Type Description
    System.Int64

    Methods

    | Improve this Doc View Source

    AlignObjectSize(Int64)

    Aligns an object size to be the next multiple of NUM_BYTES_OBJECT_ALIGNMENT.

    Declaration
    public static long AlignObjectSize(long size)
    Parameters
    Type Name Description
    System.Int64 size
    Returns
    Type Description
    System.Int64
    | Improve this Doc View Source

    HumanReadableUnits(Int64)

    Returns size in human-readable units (GB, MB, KB or bytes).

    Declaration
    public static string HumanReadableUnits(long bytes)
    Parameters
    Type Name Description
    System.Int64 bytes
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    HumanReadableUnits(Int64, IFormatProvider)

    Returns size in human-readable units (GB, MB, KB or bytes).

    Declaration
    public static string HumanReadableUnits(long bytes, IFormatProvider df)
    Parameters
    Type Name Description
    System.Int64 bytes
    System.IFormatProvider df
    Returns
    Type Description
    System.String
    | Improve this Doc View Source

    HumanSizeOf(Object)

    Return a human-readable size of a given object.

    Declaration
    public static string HumanSizeOf(object object)
    Parameters
    Type Name Description
    System.Object object
    Returns
    Type Description
    System.String
    See Also
    SizeOf(Object)
    HumanReadableUnits(Int64)
    | Improve this Doc View Source

    ShallowSizeOf(Object)

    Estimates a "shallow" memory usage of the given object. For arrays, this will be the memory taken by array storage (no subreferences will be followed). For objects, this will be the memory taken by the fields.

    .NET object alignments are also applied.

    Declaration
    public static long ShallowSizeOf(object obj)
    Parameters
    Type Name Description
    System.Object obj
    Returns
    Type Description
    System.Int64
    | Improve this Doc View Source

    ShallowSizeOfInstance(Type)

    Returns the shallow instance size in bytes an instance of the given class would occupy. This works with all conventional classes and primitive types, but not with arrays (the size then depends on the number of elements and varies from object to object).

    Declaration
    public static long ShallowSizeOfInstance(Type clazz)
    Parameters
    Type Name Description
    System.Type clazz
    Returns
    Type Description
    System.Int64
    Exceptions
    Type Condition
    System.ArgumentException

    if clazz is an array class.

    See Also
    ShallowSizeOf(Object)
    | Improve this Doc View Source

    SizeOf(Boolean[])

    Returns the size in bytes of the bool[] object.

    Declaration
    public static long SizeOf(bool[] arr)
    Parameters
    Type Name Description
    System.Boolean[] arr
    Returns
    Type Description
    System.Int64
    | Improve this Doc View Source

    SizeOf(Byte[])

    Returns the size in bytes of the byte[] object.

    Declaration
    public static long SizeOf(byte[] arr)
    Parameters
    Type Name Description
    System.Byte[] arr
    Returns
    Type Description
    System.Int64
    | Improve this Doc View Source

    SizeOf(Char[])

    Returns the size in bytes of the char[] object.

    Declaration
    public static long SizeOf(char[] arr)
    Parameters
    Type Name Description
    System.Char[] arr
    Returns
    Type Description
    System.Int64
    | Improve this Doc View Source

    SizeOf(Double[])

    Returns the size in bytes of the double[] object.

    Declaration
    public static long SizeOf(double[] arr)
    Parameters
    Type Name Description
    System.Double[] arr
    Returns
    Type Description
    System.Int64
    | Improve this Doc View Source

    SizeOf(Int16[])

    Returns the size in bytes of the short[] object.

    Declaration
    public static long SizeOf(short[] arr)
    Parameters
    Type Name Description
    System.Int16[] arr
    Returns
    Type Description
    System.Int64
    | Improve this Doc View Source

    SizeOf(Int32[])

    Returns the size in bytes of the int[] object.

    Declaration
    public static long SizeOf(int[] arr)
    Parameters
    Type Name Description
    System.Int32[] arr
    Returns
    Type Description
    System.Int64
    | Improve this Doc View Source

    SizeOf(Int64[])

    Returns the size in bytes of the long[] object.

    Declaration
    public static long SizeOf(long[] arr)
    Parameters
    Type Name Description
    System.Int64[] arr
    Returns
    Type Description
    System.Int64
    | Improve this Doc View Source

    SizeOf(Object)

    Estimates the RAM usage by the given object. It will walk the object tree and sum up all referenced objects.

    Resource Usage: this method internally uses a set of every object seen during traversals so it does allocate memory (it isn't side-effect free). After the method exits, this memory should be GCed.

    Declaration
    public static long SizeOf(object obj)
    Parameters
    Type Name Description
    System.Object obj
    Returns
    Type Description
    System.Int64
    | Improve this Doc View Source

    SizeOf(SByte[])

    Returns the size in bytes of the sbyte[] object.

    Declaration
    [CLSCompliant(false)]
    public static long SizeOf(sbyte[] arr)
    Parameters
    Type Name Description
    System.SByte[] arr
    Returns
    Type Description
    System.Int64
    | Improve this Doc View Source

    SizeOf(Single[])

    Returns the size in bytes of the float[] object.

    Declaration
    public static long SizeOf(float[] arr)
    Parameters
    Type Name Description
    System.Single[] arr
    Returns
    Type Description
    System.Int64
    | Improve this Doc View Source

    SizeOf(UInt16[])

    Returns the size in bytes of the ushort[] object.

    Declaration
    [CLSCompliant(false)]
    public static long SizeOf(ushort[] arr)
    Parameters
    Type Name Description
    System.UInt16[] arr
    Returns
    Type Description
    System.Int64
    | Improve this Doc View Source

    SizeOf(UInt32[])

    Returns the size in bytes of the uint[] object.

    Declaration
    [CLSCompliant(false)]
    public static long SizeOf(uint[] arr)
    Parameters
    Type Name Description
    System.UInt32[] arr
    Returns
    Type Description
    System.Int64
    | Improve this Doc View Source

    SizeOf(UInt64[])

    Returns the size in bytes of the ulong[] object.

    Declaration
    [CLSCompliant(false)]
    public static long SizeOf(ulong[] arr)
    Parameters
    Type Name Description
    System.UInt64[] arr
    Returns
    Type Description
    System.Int64

    Extension Methods

    Number.IsNumber(Object)

    See Also

    SizeOf(Object)
    ShallowSizeOf(Object)
    ShallowSizeOfInstance(Type)
    • Improve this Doc
    • View Source
    Back to top Copyright © 2019 Licensed to the Apache Software Foundation (ASF)