0

I am new to RUST as well as for programming. I just wrote LED blinking program on raspberry pi 3 using RUST language. It worked well. My debug binary file size is 4.7MB. Its really huge. So I released the file and it got reduced to 2.5MB. I found that due to default operation of Jemalloc, Debug symbol and Panic Rust executables are very large. Can somebody help me out how much memory is consumed by Jemalloc, Debug Symbol and Panic? How to find this ? where it is located? How can I remove or deallocate Jemalloc?

I am working with Rust 1.38.0 stable version on Raspberry pi 3 using Visual studio code IDE.

main.rs file

use rust_gpiozero::*;
use std::thread;
use std::time::Duration;


fn main() {
  //create a new LEd attached to pin 17
  let led = LED::new(17);

  //blink the led 5 times
  for _ in 0.. 5{
      led.on();
      thread::sleep(Duration::from_secs(10));
      led.off();
      thread::sleep(Duration::from_secs(10));

  }
}

cargo.toml file

[package]
name = "led_blink"
version = "0.1.0"
authors = ["pi"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
libc = "0.2"
rust_gpiozero = "0.2.0"

[profile.release]
codegen-units = 1

I want to know about how much memory consumed by jemalloc, debug symbol and panic in total size. and how to remove/Deactivate all three operation by default. Looking for help, Thank you

edwardw
  • 12,652
  • 3
  • 40
  • 51
ganesh
  • 43
  • 1
  • 6
  • 1
    Are you interested in the memory or in the impact on the executable size ? – Denys Séguret Oct 16 '19 at 08:01
  • Main interest is to know about memory, but impact on executable size also matters a lot. Basically I need to know about both :) – ganesh Oct 16 '19 at 08:15
  • As far as I know, jemalloc doesn't ship with Rust anymore. It should use the system allocator. See [this post from November 2018](https://internals.rust-lang.org/t/jemalloc-was-just-removed-from-the-standard-library/8759) and [this PR](https://github.com/rust-lang/rust/pull/55238). This shipped in 1.32.0. – SplittyDev Oct 16 '19 at 10:47

0 Answers0