File tree 2 files changed +4
-26
lines changed
2 files changed +4
-26
lines changed Original file line number Diff line number Diff line change @@ -48,25 +48,9 @@ use core::ptr::NonNull;
48
48
/// This is based on `malloc` on Unix platforms and `HeapAlloc` on Windows,
49
49
/// plus related functions.
50
50
///
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.
70
54
#[ stable( feature = "alloc_system_type" , since = "1.28.0" ) ]
71
55
pub struct System ;
72
56
Original file line number Diff line number Diff line change 12
12
//!
13
13
//! In a given program, the standard library has one “global” memory allocator
14
14
//! that is used for example by `Box<T>` and `Vec<T>`.
15
+ //! The default global allocator is [`System`].
15
16
//!
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
23
17
//! [`System`]: struct.System.html
24
18
//!
25
19
//! # The `#[global_allocator]` attribute
You can’t perform that action at this time.
0 commit comments