size

package
v1.1.0-beta.0...-2a72e7f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KB is the kilobytes.
	KB = uint64(1024)
	// MB is the megabytes.
	MB = KB * 1024
	// GB is the gigabytes.
	GB = MB * 1024
	// TB is the terabytes.
	TB = GB * 1024
	// PB is the petabytes.
	PB = TB * 1024
)
View Source
const (
	// SizeOfSlice is the memory itself used, excludes the elements' memory
	SizeOfSlice = int64(unsafe.Sizeof(*new([]int)))

	// SizeOfByte is the memory each byte occupied
	SizeOfByte = int64(unsafe.Sizeof(*new(byte)))

	// SizeOfString is the memory string itself occupied
	SizeOfString = int64(unsafe.Sizeof(*new(string)))

	// SizeOfBool is the memory each bool occupied
	SizeOfBool = int64(unsafe.Sizeof(*new(bool)))

	// SizeOfPointer is the memory each pointer occupied
	SizeOfPointer = int64(unsafe.Sizeof(new(int)))

	// SizeOfInterface is the memory each interface occupied, exclude the real type memory usage
	SizeOfInterface = int64(unsafe.Sizeof(*new(any)))

	// SizeOfFloat64 is the memory each float64 occupied
	SizeOfFloat64 = int64(unsafe.Sizeof(*new(float64)))

	// SizeOfUint64 is the memory each uint64 occupied
	SizeOfUint64 = int64(unsafe.Sizeof(*new(uint64)))

	// SizeOfInt32 is the memory each int32 occupied
	SizeOfInt32 = int64(unsafe.Sizeof(*new(int32)))

	// SizeOfInt is the memory each int occupied
	SizeOfInt = int64(unsafe.Sizeof(*new(int)))

	// SizeOfUint8 is the memory each uint8 occupied
	SizeOfUint8 = int64(unsafe.Sizeof(*new(uint8)))

	// SizeOfUint is the memory each uint occupied
	SizeOfUint = int64(unsafe.Sizeof(*new(uint)))

	// SizeOfFunc is the memory each function occupied
	SizeOfFunc = int64(unsafe.Sizeof(*new(func())))

	// SizeOfInt64 is the memory each int64 occupied
	SizeOfInt64 = int64(unsafe.Sizeof(*new(int64)))

	// SizeOfMap is the memory each map itself occupied
	SizeOfMap = int64(unsafe.Sizeof(*new(map[int]int)))
)

below constants are the size of commonly used types, for memory trace

Variables

This section is empty.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL