Class RamUsageEstimator
Estimates the size (memory representation) of .NET objects.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Inheritance
RamUsageEstimator
Assembly: Lucene.Net.dll
Syntax
public sealed class RamUsageEstimator
Fields
Number of bytes to represent an array header (no content, but with alignments).
Declaration
public static readonly int NUM_BYTES_ARRAY_HEADER
Field Value
NUM_BYTES_BOOLEAN
Estimates the size (memory representation) of .NET objects.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public const int NUM_BYTES_BOOLEAN = 1
Field Value
See Also
NUM_BYTES_BYTE
Estimates the size (memory representation) of .NET objects.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public const int NUM_BYTES_BYTE = 1
Field Value
See Also
NUM_BYTES_CHAR
Estimates the size (memory representation) of .NET objects.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public const int NUM_BYTES_CHAR = 2
Field Value
See Also
NUM_BYTES_DOUBLE
Estimates the size (memory representation) of .NET objects.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Declaration
public const int NUM_BYTES_DOUBLE = 8
Field Value
See Also
NUM_BYTES_INT16
NOTE: This was NUM_BYTES_SHORT in Lucene
Declaration
public const int NUM_BYTES_INT16 = 2
Field Value
See Also
NUM_BYTES_INT32
NOTE: This was NUM_BYTES_INT in Lucene
Declaration
public const int NUM_BYTES_INT32 = 4
Field Value
See Also
NUM_BYTES_INT64
NOTE: This was NUM_BYTES_LONG in Lucene
Declaration
public const int NUM_BYTES_INT64 = 8
Field Value
See Also
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
See Also
Number of bytes to represent an object header (no fields, no alignments).
Declaration
public static readonly int NUM_BYTES_OBJECT_HEADER
Field Value
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
See Also
NUM_BYTES_SINGLE
NOTE: This was NUM_BYTES_FLOAT in Lucene
Declaration
public const int NUM_BYTES_SINGLE = 4
Field Value
See Also
ONE_GB
Declaration
public const long ONE_GB = 1073741824
Field Value
See Also
ONE_KB
Declaration
public const long ONE_KB = 1024
Field Value
See Also
ONE_MB
Declaration
public const long ONE_MB = 1048576
Field Value
See Also
Methods
AlignObjectSize(long)
Declaration
public static long AlignObjectSize(long size)
Parameters
Type |
Name |
Description |
long |
size |
|
Returns
See Also
HumanReadableUnits(long)
Returns size
in human-readable units (GB, MB, KB or bytes).
Declaration
public static string HumanReadableUnits(long bytes)
Parameters
Type |
Name |
Description |
long |
bytes |
|
Returns
See Also
Returns size
in human-readable units (GB, MB, KB or bytes).
Declaration
public static string HumanReadableUnits(long bytes, IFormatProvider df)
Parameters
Returns
HumanSizeOf(object)
Return a human-readable size of a given object.
Declaration
public static string HumanSizeOf(object @object)
Parameters
Type |
Name |
Description |
object |
object |
|
Returns
See Also
Return a human-readable size of a given object.
Declaration
public static string HumanSizeOf(object @object, IFormatProvider df)
Parameters
Returns
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 |
object |
obj |
|
Returns
See Also
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 |
Type |
clazz |
|
Returns
Exceptions
See Also
SizeOf(bool[])
Returns the size in bytes of the bool[] object.
Declaration
public static long SizeOf(bool[] arr)
Parameters
Type |
Name |
Description |
bool[] |
arr |
|
Returns
See Also
SizeOf(byte[])
Returns the size in bytes of the byte[] object.
Declaration
public static long SizeOf(byte[] arr)
Parameters
Type |
Name |
Description |
byte[] |
arr |
|
Returns
See Also
SizeOf(char[])
Returns the size in bytes of the char[] object.
Declaration
public static long SizeOf(char[] arr)
Parameters
Type |
Name |
Description |
char[] |
arr |
|
Returns
See Also
SizeOf(double[])
Returns the size in bytes of the double[] object.
Declaration
public static long SizeOf(double[] arr)
Parameters
Type |
Name |
Description |
double[] |
arr |
|
Returns
See Also
SizeOf(short[])
Returns the size in bytes of the short[] object.
Declaration
public static long SizeOf(short[] arr)
Parameters
Type |
Name |
Description |
short[] |
arr |
|
Returns
See Also
SizeOf(int[])
Returns the size in bytes of the int[] object.
Declaration
public static long SizeOf(int[] arr)
Parameters
Type |
Name |
Description |
int[] |
arr |
|
Returns
See Also
SizeOf(long[])
Returns the size in bytes of the long[] object.
Declaration
public static long SizeOf(long[] arr)
Parameters
Type |
Name |
Description |
long[] |
arr |
|
Returns
See Also
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 |
object |
obj |
|
Returns
See Also
SizeOf(sbyte[])
Returns the size in bytes of the sbyte[] object.
Declaration
[CLSCompliant(false)]
public static long SizeOf(sbyte[] arr)
Parameters
Type |
Name |
Description |
sbyte[] |
arr |
|
Returns
See Also
SizeOf(float[])
Returns the size in bytes of the float[] object.
Declaration
public static long SizeOf(float[] arr)
Parameters
Type |
Name |
Description |
float[] |
arr |
|
Returns
See Also
SizeOf(ushort[])
Returns the size in bytes of the ushort[] object.
Declaration
[CLSCompliant(false)]
public static long SizeOf(ushort[] arr)
Parameters
Type |
Name |
Description |
ushort[] |
arr |
|
Returns
See Also
SizeOf(uint[])
Returns the size in bytes of the uint[] object.
Declaration
[CLSCompliant(false)]
public static long SizeOf(uint[] arr)
Parameters
Type |
Name |
Description |
uint[] |
arr |
|
Returns
See Also
SizeOf(ulong[])
Returns the size in bytes of the ulong[] object.
Declaration
[CLSCompliant(false)]
public static long SizeOf(ulong[] arr)
Parameters
Type |
Name |
Description |
ulong[] |
arr |
|
Returns
See Also
See Also