Skip to content

Deferred object destruction for shared_ptr #111

Open

Description

@ohhmm

Once during profiling, I noticed that deletion has major performance impact.
Since I don't rely on object under shared_ptr destruction end, I decided to defer the destruction to increase overall performance of getting results.
My solution looks like this: void DispatchDispose(std::shared_ptr<void>&&);: https://github.com/ohhmm/openmind/blob/d2a58112b8e341e8733466e9710feb2ce11d882d/omnn/rt/GC.h#L19

My thought was about that in fact hardly anyone rely on last shared_ptr deletion end to continue code execution. Its only goal is to cleanup resource, but it does not matter when.

I guess that may be useful to have resource cleanup governors for shared_ptr or new kind of smart pointers for this.

Activity

  1. pdimov commented on Mar 1, 2024

    @pdimov
    Member

    If you control how the shared pointers are created, you can use a "deferred deleter" for this, e.g.

    https://www.boost.org/doc/libs/1_84_0/libs/smart_ptr/doc/html/smart_ptr.html#techniques_delayed_deallocation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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