MEMHOG(8)

๐Ÿ“ฆ
version 2.0.19.14.g690a72c ยท 2 versions
  • 2.0.19.14.g690a72c ยท alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 2.0.16 ยท debian bookworm, ubuntu jammy
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

โœจ NAME โœจ

okay so bestie, memhog is literally the tool that allocates memory with a policy attached, and it's for testing ๐Ÿงช๐Ÿ’– It's giving stress test energy. memhog - Allocates memory with policy for testing.

๐ŸŽ€ SYNOPSIS ๐ŸŽ€

memhog [ -r<NUM> ] [ size kmg ] [ policy nodeset ] [ -f<filename> ]

๐Ÿ’… DESCRIPTION ๐Ÿ’…

ngl this is the core of it. memhog mmaps a memory region for a given size and sets the numa policy (if you specify one) โœจ Then it keeps updating that memory region for however many iterations you ask for, using memset. Iconic.

Here are the flags you can slap on:

  • -r<num> โ€” repeat the memset NUM times ๐Ÿ”
  • -f<file> โ€” open a file to use for mmap backing ๐Ÿ“
  • -H โ€” disable transparent hugepages, no thanks ๐Ÿ™…โ€โ™€๏ธ
  • -size โ€” the allocation size in bytes. You can add a case-insensitive order suffix: G for gigabyte, M for megabyte, K for kilobyte ๐ŸŒธ

Now the numa policies, which are lowkey the best part ๐Ÿ‘‘

Supported numa-policies:

  • interleave โ€” memory gets allocated round robin across the nodes ๐Ÿฆ‹ If memory can't be allocated on the current interleave node, it falls back to other nodes. You can specify multiple nodes here.
  • membind โ€” only allocate memory from these nodes. Allocation will fail if there isn't enough memory available on them, so no sneaking off to other nodes ๐Ÿ™…โ€โ™€๏ธ You can specify multiple nodes.
  • preferred โ€” preferably allocate memory on the node you pick, but if it can't fit there, fall back to other nodes ๐ŸŒˆ This one only takes a single node number, bestie.
  • default โ€” memory gets allocated on the local node, meaning whichever node the thread is running on ๐Ÿงš

๐Ÿ“ EXAMPLES ๐Ÿ“

okay examples time, I'm obsessed with these ๐Ÿ˜ญ

Allocate a 1G region, mmap backed by the memhog.mmap file, membind to node 0, and repeat the test 6 times:

memhog -r6 1G --membind 0 -fmemhog.mmap

Allocate a 1G region, interleave across nodes 0, 1, 2, and 3, and repeat the test 4 times:

memhog -r4 1G --interleave 0-3

Allocate a 1G region with the (implicit) default policy, and repeat the test 8 times:

memhog -r8 1G

๐Ÿซถ AUTHORS ๐Ÿซถ

Andi Kleen (ak@suse.de) โ€” the legend herself ๐Ÿ‘‘

๐Ÿ”ฅ LICENSE ๐Ÿ”ฅ

GPL v2 ๐Ÿ’œ

๐Ÿฆ‹ SEE ALSO ๐Ÿฆ‹

mmap(2), memset(3), numactl(8), numastat(8) โœจ


okay bestie that's everything ๐Ÿฅน memhog came from SuSE Labs, 2003,2004, and it's still giving ๐ŸŽ€ Stay iconic, stay testing ๐Ÿ’–๐Ÿงš