These are chat archives for rust-lang/rust

30th
Jul 2016
LeonineKing1199
@LeonineKing1199
Jul 30 2016 01:54
fn main() {
    println!("Hello, world!");
}
==9674== Memcheck, a memory error detector
==9674== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==9674== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==9674== Command: ./hello-world
==9674== 
Hello, world!
==9674== 
==9674== HEAP SUMMARY:
==9674==     in use at exit: 0 bytes in 0 blocks
==9674==   total heap usage: 21 allocs, 21 frees, 3,592 bytes allocated
==9674== 
==9674== All heap blocks were freed -- no leaks are possible
==9674== 
==9674== For counts of detected and suppressed errors, rerun with: -v
==9674== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
All I literally compiled was the "Hello, world" example too O_o
Peter Atashian
@retep998
Jul 30 2016 01:55
@LeonineKing1199 Looks normal to me
LeonineKing1199
@LeonineKing1199
Jul 30 2016 01:55
Freaking 21 allocations just for printing a string?!
Peter Atashian
@retep998
Jul 30 2016 01:55
@LeonineKing1199 What's the number of allocations without the println!?
LeonineKing1199
@LeonineKing1199
Jul 30 2016 01:55
I'm just kind of shocked.
mhsjlw
@mhsjlw
Jul 30 2016 01:55
no leaks, I wouldn't be complaining
:P
Peter Atashian
@retep998
Jul 30 2016 01:56
So we know how much is being spent on the entry point and such
LeonineKing1199
@LeonineKing1199
Jul 30 2016 01:56
How else do you print in Rust lol?
no leaks, I wouldn't be complaining
XD
mhsjlw
@mhsjlw
Jul 30 2016 01:56
because you're using macros, and allocating the char* in memory
Peter Atashian
@retep998
Jul 30 2016 01:57
I still say compare the number of allocations to the number without the println
so you know how much it is really using
mhsjlw
@mhsjlw
Jul 30 2016 01:57
^
Peter Atashian
@retep998
Jul 30 2016 01:57
Remember, a lot of stuff happens before your main function is even called
LeonineKing1199
@LeonineKing1199
Jul 30 2016 02:00
Oh wow, Rust's main loop is 13 allocations for me
Which means 8 are for printing alone O_o
Dude...
Why?
mhsjlw
@mhsjlw
Jul 30 2016 02:00
easy, more allocations means a better language
1 alloc in C is < 21 allocs in Rust
LeonineKing1199
@LeonineKing1199
Jul 30 2016 02:01
Freaking lol.
mhsjlw
@mhsjlw
Jul 30 2016 02:01
so technically speaking Rust > C because there are more allocations
LeonineKing1199
@LeonineKing1199
Jul 30 2016 02:01
I'm just so confused because I've no idea where they're coming from.
mhsjlw
@mhsjlw
Jul 30 2016 02:01
the more memory that is leaked also determines the abilities of a language
xD
tbh, I'm curious too
LeonineKing1199
@LeonineKing1199
Jul 30 2016 02:02
So much for zero-cost abstractions...
Peter Atashian
@retep998
Jul 30 2016 03:41
@LeonineKing1199 I could call WriteConsoleW on windows to directly write to the console, but even that would involve at least one allocation to convert from utf-8 to utf-16
@LeonineKing1199 What happens if you println twice? Does it go from 21 to 29?
I wonder how much of those 8 allocations are only done the first time you print stuff
LeonineKing1199
@LeonineKing1199
Jul 30 2016 06:26
Do you not have Val grins?
Lol valfrind
I hate my phone
Peter Atashian
@retep998
Jul 30 2016 07:34
I'm on Windows so I can't verify your non-windows specific results
Vladyslav M.
@dywedir
Jul 30 2016 08:28
fn main() {
    println!("Hello, world!");
}
==18407== Memcheck, a memory error detector
==18407== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==18407== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==18407== Command: ./testt
==18407== 
==18407== 
==18407== HEAP SUMMARY:
==18407==     in use at exit: 0 bytes in 0 blocks
==18407==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==18407== 
==18407== All heap blocks were freed -- no leaks are possible
==18407== 
==18407== For counts of detected and suppressed errors, rerun with: -v
==18407== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
:D
Peter Atashian
@retep998
Jul 30 2016 09:19
@N-006 I think your memcheck might be broken :stuck_out_tongue:
Vladyslav M.
@dywedir
Jul 30 2016 09:24
@retep998 no, it's ok! :innocent:
Erik Hedvall
@Ogeon
Jul 30 2016 09:25
I'm also getting 0 heap usage with rustc 1.10
...on Linux
Lilian Anatolie Moraru
@lilianmoraru
Jul 30 2016 09:44
0 here too in debug and release mode.
Peter Atashian
@retep998
Jul 30 2016 09:51
What happens if you deliberately allocate memory with Vec or String?
Lilian Anatolie Moraru
@lilianmoraru
Jul 30 2016 10:33
Same, 0.
I tried with vec, one sec
Yep, 0 with both String and Vec
Lilian Anatolie Moraru
@lilianmoraru
Jul 30 2016 10:39
@retep998 Cmon, I've ran under valgrind more complex applications like racer and still 0 leaks.
Vladyslav M.
@dywedir
Jul 30 2016 10:40
Just add
#![feature(alloc_system)]
extern crate alloc_system;
Lilian Anatolie Moraru
@lilianmoraru
Jul 30 2016 10:40
That's not from Rust
I think that's from Dropbox
And who knows, that allocator might leak intentionally.
Nvm, I've mistaken with something else

Yes, using

#![feature(alloc_system)]
extern crate alloc_system;

and Not Rust's allocator, it is leaking...

But you basically intentionally asked for it to leak in that case
Lilian Anatolie Moraru
@lilianmoraru
Jul 30 2016 10:46
Btw, I have mistaken it with this one: https://github.com/dropbox/rust-alloc-no-stdlib
LeonineKing1199
@LeonineKing1199
Jul 30 2016 18:19
Oh, that's so interesting.
All I did was use sudo apt-get install rustc
I'm on Ubuntu 16.04
Maybe it's my version of valgrind?
I'm on 3.11 of that