Skip to content

Memory leak when Mock aliases a method #67

@MaxLap

Description

@MaxLap

When Mock.install_method aliases an existing method (https://github.com/ruby/mspec/blob/master/lib/mspec/mocks/mock.rb#L63), it does so using a symbol that is unique (it has the #object_id). And since that symbol is used as method, even if the method gets erased, the symbol remains.

This means that if a spec was to run multiple time (ex, using repeat), or some custom made mechanism, specs using Mock.install_method appear to have a memory leak (They technically do).

If those names were instead reused, such as by incrementing from 1, storing the number, and then on clenaup, resetting to 1, the leaky side of this would be removed.

Thoughts?

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