Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit 24c4351

Browse files
Andronik Ordian5chdn
authored andcommitted
Use system allocator when profiling memory (#8831)
1 parent a6d267a commit 24c4351

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ slow-blocks = ["ethcore/slow-blocks"]
9898
secretstore = ["ethcore-secretstore"]
9999
final = ["parity-version/final"]
100100
deadlock_detection = ["parking_lot/deadlock_detection"]
101+
# to create a memory profile (requires nightly rust), use e.g.
102+
# `heaptrack /path/to/parity <parity params>`,
103+
# to visualize a memory profile, use `heaptrack_gui`
104+
# or
105+
# `valgrind --tool=massif /path/to/parity <parity params>`
106+
# and `massif-visualizer` for visualization
107+
memory_profiling = []
101108

102109
[lib]
103110
path = "parity/lib.rs"

parity/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
//! Ethcore client application.
1818
1919
#![warn(missing_docs)]
20+
#![cfg_attr(feature = "memory_profiling", feature(alloc_system, global_allocator, allocator_api))]
2021

2122
extern crate ansi_term;
2223
extern crate docopt;
@@ -91,6 +92,9 @@ extern crate pretty_assertions;
9192
#[cfg(test)]
9293
extern crate tempdir;
9394

95+
#[cfg(feature = "memory_profiling")]
96+
extern crate alloc_system;
97+
9498
mod account;
9599
mod blockchain;
96100
mod cache;
@@ -125,10 +129,16 @@ use cli::Args;
125129
use configuration::{Cmd, Execute};
126130
use deprecated::find_deprecated;
127131
use ethcore_logger::setup_log;
132+
#[cfg(feature = "memory_profiling")]
133+
use alloc_system::System;
128134

129135
pub use self::configuration::Configuration;
130136
pub use self::run::RunningClient;
131137

138+
#[cfg(feature = "memory_profiling")]
139+
#[global_allocator]
140+
static A: System = System;
141+
132142
fn print_hash_of(maybe_file: Option<String>) -> Result<String, String> {
133143
if let Some(file) = maybe_file {
134144
let mut f = BufReader::new(File::open(&file).map_err(|_| "Unable to open file".to_owned())?);

0 commit comments

Comments
 (0)