mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 06:24:58 +00:00

Use LibCore ArgsParser to parse the parameters instead of using the raw strings from the argv (Main::Arguments) array. Also, use indicative names for variables in the code so the utility code is more understandable.
99 lines
1.8 KiB
Markdown
99 lines
1.8 KiB
Markdown
## Name
|
|
|
|
allocate - allocate memory
|
|
|
|
## Synopsis
|
|
|
|
```**sh
|
|
$ allocate [--unit B/KiB/MiB/GiB] [--sleep-time N] [number]
|
|
```
|
|
|
|
## Description
|
|
|
|
`allocate` allocates a specific amount of virtual memory. If nothing is specified
|
|
then it will allocate 100 bytes of memory.
|
|
If `number` is specified without `unit`, it will default to `number` of bytes.
|
|
It also writes to each allocated page and then sleeps for N seconds (by default 10).
|
|
It is primarily used to test the kernel's memory management capabilities.
|
|
|
|
## Options
|
|
|
|
* `-u`, `--size-unit`: Allocation's Size Unit (Base 2 units - B, KiB, MiB or GiB)
|
|
* `-n`, `--sleep-time`: Number of seconds to sleep before freeing memory
|
|
|
|
## Examples
|
|
|
|
```sh
|
|
$ allocate 500
|
|
allocating memory (500 bytes)...
|
|
done in 0ms
|
|
writing one byte to each page of allocated memory...
|
|
done in 0ms
|
|
sleeping for 10 seconds...
|
|
0
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
done.
|
|
freeing memory...
|
|
done in 0ms
|
|
|
|
$ allocate 500 -u KiB
|
|
allocating memory (512000 bytes)...
|
|
done in 0ms
|
|
writing one byte to each page of allocated memory...
|
|
step took 1ms (46.875MiB/s)
|
|
step took 1ms (46.875MiB/s)
|
|
step took 1ms (46.875MiB/s)
|
|
step took 1ms (46.875MiB/s)
|
|
step took 1ms (46.875MiB/s)
|
|
step took 1ms (46.875MiB/s)
|
|
step took 1ms (46.875MiB/s)
|
|
step took 1ms (46.875MiB/s)
|
|
step took 1ms (46.875MiB/s)
|
|
step took 1ms (46.875MiB/s)
|
|
done in 4ms
|
|
sleeping for 10 seconds...
|
|
0
|
|
1
|
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
done.
|
|
freeing memory...
|
|
done in 0ms
|
|
|
|
$ allocate -u KiB -n 2 500
|
|
allocating memory (512000 bytes)...
|
|
done in 0ms
|
|
writing one byte to each page of allocated memory...
|
|
step took 1ms (46.875MiB/s)
|
|
step took 1ms (46.875MiB/s)
|
|
step took 1ms (46.875MiB/s)
|
|
step took 1ms (46.875MiB/s)
|
|
step took 1ms (46.875MiB/s)
|
|
step took 1ms (46.875MiB/s)
|
|
step took 1ms (46.875MiB/s)
|
|
step took 1ms (46.875MiB/s)
|
|
step took 1ms (46.875MiB/s)
|
|
step took 1ms (46.875MiB/s)
|
|
done in 0ms
|
|
sleeping for 2 seconds...
|
|
0
|
|
1
|
|
done.
|
|
freeing memory...
|
|
done in 0ms
|
|
|
|
```
|