RAM Chomper
-----------

This command line program will allocate a certain amount of RAM (default: 16GB)
and then free it after a keypress or a certain duration.

To allocate 4GB: `ram_chomper 4`. To allocate 16GB and wait 10 seconds instead
of waiting for a keypress: `ram_chomper --wait 10`.

# Technical details 
The allocation is simple vector of vectors (`.with_capacity()`) filled with
random integers (using `fastrand` crate) to prevent any potential 
memory compression. The allocation is done in 64MB blocks by default,
and if desired RAM and block size aren't perfectly divisible, 
the total allocated RAM gets rounded down.

The program currently creates overhead about 8-40MB for the 16GB eaten up.

This was a coding exercise and I didn't have breakfast yet so the code isn't
very pretty or idiomatic, but it gets the job done.


The program displays a warning if you plan to allocate over 50% of your RAM
and a more severe warning if you try to use over 80%.

## Usage

```shell
# Allocate 24576MB in 256MB blocks
ram_chomper 24 --block-size-mb 256

# Allocate only 900MB = 1024MB gets divided into three 300MB blocks 
ram_chomper 1 -b 300

# Allocate 1GB and free it up after 20s, without waiting for a keypress.
ram_chomper 1 --wait 20

# Allocate 100GB and ignore warnings about system instability. This genuinely
# might make your OS misbehave! Or not if you have 128GB+ RAM idk.
ram_chomper 100 --ignore-warnings

```

## Benchmarking notes and performance considerations

* This does not change anything about how OS behaves, and there is no guarantee 
  that the memory used will remain in RAM! E.g. if you have 32GB, allocate 16GB
  with ram_chomper, and then run a huge RAM-intensive workload, there isn't any
  guaranteed behavior of what will your OS move from RAM to swap. It will not
  realistically simulate having less physical RAM in this case.
* Allocated data is filled with random numbers, which uses some CPU (single core). 
  Depending on your RAM and CPU speed this can take 0.25~2s per GB.
* While waiting for a keypress or timeout, ~0% of CPU is used.
* 1MB = 1024 x 1024 bytes, 1GB = 1024MB etc. (Get serious, SI.)

