Creating and deleting multiple edits with tracktion engine

I have a small working POC application running that instantiates a tracktion engine and an edit.

I also have a suite of unit tests that all use an engine and an edit instance. Since initialisation of the engine takes a little while for every test, the test suite runs rather slow.

To solve this I’m trying to reuse the same engine instance across all tests in the suite, just creating a fresh edit for each test case. Unfortunately, I’m seeing a bunch of leaked objects when edits go out of scope and I’m not sure how to fix it.

I’m guessing there must be a way to cleanly create and delete multiple edits with the same engine instance? If so, can anyone tell me how?

Are you sure you’re deleting the Edit correctly? What objects are leaking?
This is the same approach we use for our Unit Tests which you can see throughout the code base.

I guess I’m trying to ask what the “correct” way to delete an edit is?

I’ll have a look at your unit tests.

You should just be able to delete it, as long as it’s on the message thread.

Thanks for the hint about calling from the message thread. Turns out the problem occurred because I was not keeping the juce MessageManager alive across tests.

If anyone is interested in using Tracktion Engine with Goggle Test, here is the solution I came up with:

class GlobalEnvironment : public ::testing::Environment
    void SetUp() override

    void TearDown() override
        engine = nullptr;

    static te::Engine& getEngine()
        if (engine == nullptr)
            engine = std::make_unique<te::Engine>("Test");

        return *engine;

    inline static std::unique_ptr<te::Engine> engine;

int main(int argc, char **argv)
    ::testing::InitGoogleTest(&argc, argv);
    ::testing::AddGlobalTestEnvironment(new GlobalEnvironment);

    return RUN_ALL_TESTS();
1 Like