Skip to content

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

Closed
@abhi-bit

Description

@abhi-bit

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions