Skip to content

Commit 54fa990

Browse files
committed
Update docs regarding the default global allocator
1 parent bee536e commit 54fa990

File tree

2 files changed

+4
-26
lines changed

2 files changed

+4
-26
lines changed

src/liballoc_system/lib.rs

+3-19
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,9 @@ use core::ptr::NonNull;
4848
/// This is based on `malloc` on Unix platforms and `HeapAlloc` on Windows,
4949
/// plus related functions.
5050
///
51-
/// This type can be used in a `static` item
52-
/// with the `#[global_allocator]` attribute
53-
/// to force the global allocator to be the system’s one.
54-
/// (The default is jemalloc for executables, on some platforms.)
55-
///
56-
/// ```rust
57-
/// use std::alloc::System;
58-
///
59-
/// #[global_allocator]
60-
/// static A: System = System;
61-
///
62-
/// fn main() {
63-
/// let a = Box::new(4); // Allocates from the system allocator.
64-
/// println!("{}", a);
65-
/// }
66-
/// ```
67-
///
68-
/// It can also be used directly to allocate memory
69-
/// independently of the standard library’s global allocator.
51+
/// This type can be used directly to allocate memory
52+
/// independently of the standard library’s global allocator,
53+
/// which may have been changed with the `#[global_allocator]` attribute.
7054
#[stable(feature = "alloc_system_type", since = "1.28.0")]
7155
pub struct System;
7256

src/libstd/alloc.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,8 @@
1212
//!
1313
//! In a given program, the standard library has one “global” memory allocator
1414
//! that is used for example by `Box<T>` and `Vec<T>`.
15+
//! The default global allocator is [`System`].
1516
//!
16-
//! Currently the default global allocator is unspecified.
17-
//! The compiler may link to a version of [jemalloc] on some platforms,
18-
//! but this is not guaranteed.
19-
//! Libraries, however, like `cdylib`s and `staticlib`s are guaranteed
20-
//! to use the [`System`] by default.
21-
//!
22-
//! [jemalloc]: https://github.com/jemalloc/jemalloc
2317
//! [`System`]: struct.System.html
2418
//!
2519
//! # The `#[global_allocator]` attribute

0 commit comments

Comments
 (0)