Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak with 1.0.0-beta.2 on Mac #24856

Closed
abhi-bit opened this issue Apr 27, 2015 · 6 comments
Closed

Memory leak with 1.0.0-beta.2 on Mac #24856

abhi-bit opened this issue Apr 27, 2015 · 6 comments

Comments

@abhi-bit
Copy link

Sample code used:

fn create_box() {
    let _function_box = Box::new(3i32);
}

fn main() {
    let _box_int = Box::new(5i32);

    {
        let _short_lived_box = Box::new(4i32);
    }

    for _ in 0u32..1_000_000 {
        create_box();
    }
}

Valgrind output from Linux:

==72139== Memcheck, a memory error detector
==72139== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==72139== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==72139== Command: ./raii
==72139==
==72139==
==72139== HEAP SUMMARY:
==72139==     in use at exit: 0 bytes in 0 blocks
==72139==   total heap usage: 1,000,018 allocs, 1,000,018 frees, 8,001,360 bytes allocated
==72139==
==72139== All heap blocks were freed -- no leaks are possible
==72139==
==72139== For counts of detected and suppressed errors, rerun with: -v
==72139== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Valgrind output from Mac(Yosemite):

==2290== Memcheck, a memory error detector
==2290== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==2290== Using Valgrind-3.11.0.SVN and LibVEX; rerun with -h for copyright info
==2290== Command: ./raii
==2290==
--2290-- ./raii:
--2290-- dSYM directory is missing; consider using --dsymutil=yes
==2290==
==2290== HEAP SUMMARY:
==2290==     in use at exit: 35,270 bytes in 428 blocks
==2290==   total heap usage: 1,000,517 allocs, 1,000,089 frees, 8,041,742 bytes
allocated
==2290==
==2290== LEAK SUMMARY:
==2290==    definitely lost: 16 bytes in 1 blocks
==2290==    indirectly lost: 0 bytes in 0 blocks
==2290==      possibly lost: 13,098 bytes in 118 blocks
==2290==    still reachable: 22,156 bytes in 309 blocks
==2290==         suppressed: 0 bytes in 0 blocks
==2290== Rerun with --leak-check=full to see details of leaked memory
==2290==
==2290== For counts of detected and suppressed errors, rerun with: -v
==2290== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Please let me know if you aren't able to replicate this issue, I could pass valgrind output with --leak-check=full --show-reachable=yes

Rust Version info:

rustc 1.0.0-beta.2 (e9080ec39 2015-04-16) (built 2015-04-16)
binary: rustc
commit-hash: e9080ec39d9a44eb0773d648b348575b19f655e5
commit-date: 2015-04-16
build-date: 2015-04-16
host: x86_64-apple-darwin
release: 1.0.0-beta.2
@alexcrichton
Copy link
Member

Can you pass the extra flags to valgrind? It's possible that this could just be a bunch of false positives

@sfackler
Copy link
Member

I don't think this has anything to do with Rust. A noop C program (int main() {}) has the same leakage: https://gist.github.com/sfackler/f2399049857ecd5ee5c6

@abhi-bit
Copy link
Author

valgrind dump with extra flags: https://gist.github.com/abhi-bit/94e1f4dd11a227aae24f

@sfackler maybe right, I suspect.

@alexcrichton
Copy link
Member

@abhi-bit yeah it looks like @sfackler is right, so closing this. Thanks for the report though!

@CaseyLeask
Copy link

I'm getting a memory leak on OS X with an empty main rust program, but it doesn't seem to be as serious as this one.

But I'm not getting any memory leaks with the C example.

valgrind dump with extra flags for both examples: https://gist.github.com/CaseyLeask/c8d61ec45c2e146d5c1f

@alexcrichton
Copy link
Member

@CaseyLeask that may be a dupe of #19776 as pthread destructors do not run on process exit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants