1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! An implementation of [`GlobalAlloc`] that supports memory profiling
//! and whose output reports are compatible with [`pprof`].
//!
//! The below code enables memory profiling in rust programs.
//!
//! ```no_run
//! use hala_pprof_memory::PprofAlloc;
//!
//! #[global_allocator]
//! static ALLOC: PprofAlloc = PprofAlloc(10);
//! ```
//!
//! `PprofAlloc` does not automatically generate memory profiling reports,
//! the developers need to manually call [`snapshot`] function to generate them.
//!
//! [`GlobalAlloc`]: std::alloc::GlobalAlloc
//! [`pprof`]: https://github.com/google/pprof
//!
//! ```no_run
//! use hala_pprof_memory::{PprofAlloc,snapshot};
//!
//! #[global_allocator]
//! static ALLOC: PprofAlloc = PprofAlloc(10);
//!
//! fn main() {
//!     loop {
//!         // working...
//!         // generate report.
//!         snapshot();
//!     }
//! }
//! ```

#![cfg_attr(docsrs, feature(doc_cfg))]

mod helper;
mod proto;

mod profiler;
pub use profiler::*;

#[cfg(feature = "report")]
#[cfg_attr(docsrs, doc(cfg(feature = "report")))]
mod report;

#[cfg(feature = "report")]
pub use report::*;