Coder Social home page Coder Social logo

memeat's Introduction

memeat: A Memory Eater

This utility uses mmap() and mlock() to eat up RAM. This prevents the kernel from using RAM for more useful purposes, like page caching. The utility can be used as an alternative to the mem= kernel command-line, when page caching stands in the way of testing disk performance.

Installation

Building memeat from source code is very simple and only requires a C compiler and POSIX headers. On Ubuntu, the following command will suffice to install all dependencies:

sudo apt-get install build-essential

A Makefile is provided for convenience:

make

Example Usage

This example uses iozone to show how to make file-system operations disk-bound. The experiments have been conducted on a machine with 8GB of RAM and a Western Digital Caviar Blue Serial ATA disk. We first execute:

iozone -s 1g -r 256k -i 0 -i 2

This measures a random read throughput of 4.8 GB/s. Clearly, most reads have been served from RAM. If we now eat 5 GB of RAM

sudo ./memeat 5G

and re-run the same iozone command, we obtain a random read throughput of 22 MB/s. This is the expected random read throughput of the disk, thus, we can conclude that most of the reads have been served from disk.

Notes

The Linux kernel limits the amount of memory that can be mlock(). If you run this utility as an unprivileged (non-root) user, you will most likely get the following error:

mlock() failed: Cannot allocate memory

To fix this, either run memeat as root or change the resource limits by adding the following entries to /etc/security/limits.conf:

myuser          soft     memlock         16000000
myuser          hard     memlock         16000000

This will allow the user myuser to eat up to 16 GB of RAM.

Eating too much memory will freeze your system for a while, then, the OOM killer will kick in and most likely kill memeat.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.