Login Page - Create Account

Support Board


Date/Time: Thu, 25 Jun 2026 06:16:23 +0000



Post From: Custom Study .dll does not release from Sierra Chart

[2026-06-03 20:27:34]
User166108 - Posts: 88
Sierra could add an extension so that there is a "scdll_Finalize" callback in the DLL extension so static objects/threads can be cleaned up outside of DLL main, and avoid loader lock issues (which is what will happen if you use threads in global objects like openssl, etc).

I worked around it by using a reference counted singleton which works, but it requires a study be initialized to load the object in the first place.


std::shared_ptr<GlobalObject> GlobalObject::instance()
{
auto sp = s_weak.lock();
if (!sp)
{
sp = std::shared_ptr<GlobalObject>(new GlobalObject());
s_weak = sp;
}
return sp;
}

You keep the shared_ptr in your study state and clear it on LastCallToFunction
Date Time Of Last Edit: 2026-06-03 20:31:02