#memory #page #memory-size #memory-allocator #ram

no-std page_size

Provides an easy, fast, cross-platform way to retrieve the memory page size

10 releases (5 breaking)

Uses old Rust 2015

0.6.0 Aug 3, 2023
0.5.0 Nov 20, 2022
0.4.2 Dec 20, 2019
0.4.1 Oct 10, 2017
0.1.1 Sep 21, 2017

#31 in Operating systems

Download history 86919/week @ 2024-07-17 92930/week @ 2024-07-24 74293/week @ 2024-07-31 55257/week @ 2024-08-07 60787/week @ 2024-08-14 64768/week @ 2024-08-21 58394/week @ 2024-08-28 67316/week @ 2024-09-04 61590/week @ 2024-09-11 60286/week @ 2024-09-18 65756/week @ 2024-09-25 62524/week @ 2024-10-02 68910/week @ 2024-10-09 79530/week @ 2024-10-16 76336/week @ 2024-10-23 75905/week @ 2024-10-30

312,411 downloads per month
Used in 272 crates (72 directly)

MIT/Apache

10KB
129 lines

page_size_rs is a Rust crate that provides an easy, fast, cross-platform way to retrieve the memory page size of the current system. It supports any POSIX-compliant system, Windows, and WebAssembly.

Documentation

Linux Status Build status

Introduction

Modern hardware and software tend to load data into RAM (and transfer data from RAM to disk) in discrete chunk called pages. This crate provides a helper method to retrieve the size in bytes of these pages. Since the page size should not change during execution, page_size_rs will cache the result after it has been called once.

To make this crate useful for writing memory allocators, it does not require (but can use) the Rust standard library.

Since Windows addresses sometimes have to correspond with an allocation granularity that does not always match the size of the page, I have included a method to retrieve that as well.

Example

extern crate page_size;

fn main() {
    println!("{}", page_size::get());
}

Platforms

page_size_rs should Work on Windows, any POSIX compatible system (Linux, Mac OSX, etc.), and WebAssembly.

page_size_rs is continuously tested on:

  • x86_64-unknown-linux-gnu (Linux)
  • i686-unknown-linux-gnu
  • x86_64-unknown-linux-musl (Linux w/ MUSL)
  • i686-unknown-linux-musl
  • x86_64-apple-darwin (Mac OSX)
  • i686-apple-darwin
  • x86_64-pc-windows-msvc (Windows)
  • i686-pc-windows-msvc
  • x86_64-pc-windows-gnu
  • i686-pc-windows-gnu

page_size_rs is continuously cross-compiled for:

  • arm-unknown-linux-gnueabihf
  • aarch64-unknown-linux-gnu
  • mips-unknown-linux-gnu
  • aarch64-unknown-linux-musl
  • i686-linux-android
  • x86_64-linux-android
  • arm-linux-androideabi
  • aarch64-linux-android
  • i386-apple-ios
  • x86_64-apple-ios
  • i686-unknown-freebsd
  • x86_64-unknown-freebsd
  • x86_64-unknown-netbsd
  • asmjs-unknown-emscripten
  • wasm32-wasi
  • wasm32-unknown-unknown

Dependencies

~0.4–255KB