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

Commit

Permalink
Use system allocator when profiling memory (#8831)
Browse files Browse the repository at this point in the history
  • Loading branch information
ordian authored and 5chdn committed Jun 7, 2018
1 parent a6d267a commit 24c4351
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ slow-blocks = ["ethcore/slow-blocks"]
secretstore = ["ethcore-secretstore"]
final = ["parity-version/final"]
deadlock_detection = ["parking_lot/deadlock_detection"]
# to create a memory profile (requires nightly rust), use e.g.
# `heaptrack /path/to/parity <parity params>`,
# to visualize a memory profile, use `heaptrack_gui`
# or
# `valgrind --tool=massif /path/to/parity <parity params>`
# and `massif-visualizer` for visualization
memory_profiling = []

[lib]
path = "parity/lib.rs"
Expand Down
10 changes: 10 additions & 0 deletions parity/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//! Ethcore client application.

#![warn(missing_docs)]
#![cfg_attr(feature = "memory_profiling", feature(alloc_system, global_allocator, allocator_api))]

extern crate ansi_term;
extern crate docopt;
Expand Down Expand Up @@ -91,6 +92,9 @@ extern crate pretty_assertions;
#[cfg(test)]
extern crate tempdir;

#[cfg(feature = "memory_profiling")]
extern crate alloc_system;

mod account;
mod blockchain;
mod cache;
Expand Down Expand Up @@ -125,10 +129,16 @@ use cli::Args;
use configuration::{Cmd, Execute};
use deprecated::find_deprecated;
use ethcore_logger::setup_log;
#[cfg(feature = "memory_profiling")]
use alloc_system::System;

pub use self::configuration::Configuration;
pub use self::run::RunningClient;

#[cfg(feature = "memory_profiling")]
#[global_allocator]
static A: System = System;

fn print_hash_of(maybe_file: Option<String>) -> Result<String, String> {
if let Some(file) = maybe_file {
let mut f = BufReader::new(File::open(&file).map_err(|_| "Unable to open file".to_owned())?);
Expand Down

0 comments on commit 24c4351

Please sign in to comment.