Skip to content

Possible memory leak #1

@AFx3

Description

@AFx3

Hi namrapatel,

I see a possible memory leak, tell me what do you think about it.
In the main() function, the statement: rust let register = Arc::new(AtomicPtr::new(Box::into_raw(Box::new("".to_string())))); forgets the ownership, so the meory is not automatically dropped by the compiler.
A possible solution can be taking back the ownership with a rust from_raw() .
I also had a quick run with valgrind:

==51605== LEAK SUMMARY:
==51605==    definitely lost: 24 bytes in 1 blocks
==51605==    indirectly lost: 0 bytes in 0 blocks
==51605==      possibly lost: 0 bytes in 0 blocks
==51605==    still reachable: 0 bytes in 0 blocks
==51605==         suppressed: 0 bytes in 0 blocks
==51605== 
==51605== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions