Login Page - Create Account

Support Board


Date/Time: Thu, 28 Mar 2024 17:24:53 +0000



sc Event / Flag to capture DLL release

View Count: 1638

[2019-04-07 19:55:16]
User972768 - Posts: 166
Hello,

I'm working on my custom study and came across interesting case. My study uses std::list and follows recommendations from ACSIL Programming Concepts: Allocating Memory for Classes

It all works fine until I need to reload DLL with newer code. In that case I get one of the following:
- crash of Sierra Chart software if I compile my study as "Release";
- "Debug Assertion Failed" Expression: __acrt_first_block == header popup if I compile study with debug info

Please note, that I do unload DLL while study is still active on the chart. It is kind of non-clean way, but who knows how other people will be doing it with my study. I also tried clean way: remove study from the chart and am sometimes getting same popup. So, I don't see option to unload DLL without getting this popup.

I use Visual Studio C++ 2017. If I do remote compilation then it seems that DLL is getting back in "release" type.

I believe it would be great if Sierra would initiate last call to my study before unloading DLL, so I can release memory properly. At least something similar to sc.LastCallToFunction if not just it.

And second question. Could you please post list of compiler parameters that you use for remote compilation? The reason for this question is that size of my DLL compiled under Visual Studio even with debug info is ~120k, while same code remotely compiled is over 800k. It is not that much code in my study to produce 800k binary from C++ code.

Thanks and best regards
Date Time Of Last Edit: 2019-04-07 20:04:10
[2019-04-08 18:21:25]
Sierra Chart Engineering - Posts: 104368

I believe it would be great if Sierra would initiate last call to my study before unloading DLL, so I can release memory properly. At least something similar to sc.LastCallToFunction if not just it.
But if the study is actually not getting removed from the chart, then this would not completely makes sense.

Any memory allocated by a DLL must get released and the pointers set to null before the DLL is unloaded. Otherwise, there are going to be exceptions if that memory is used again because the operating system is releasing that memory.

The reason for the larger binary size with remote compiling is that there is a different compiler being used which is apparently including a lot more standard library functions which may not be used.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2019-04-08 18:21:58
[2019-04-08 18:52:14]
User972768 - Posts: 166
Hello,

Thank you for quick reply.

Well, if study doesn't get signal to release memory in a first place when user forces unload of DLL then it is no better. My proposal is to initiate LastCallToFunction to all instances of studies from unloading DLL. This way Sierra does all it could to prevent the crash as result of such user action.

I did try to unload my DLL in a clean way (by removing this study from the chart before unloading DLL) few times and reload it again. Some times (not consistently) I was greeted with above popup. Perhaps, it is something beyond simple steps explained in the documentation on how to use STL.

Could it be something like static / dynamic linking? Basically, parameters of the linker that I'm missing.

Thanks and best regards
[2019-04-08 20:48:21]
Sierra Chart Engineering - Posts: 104368
When you remove the study from the chart, is your study releasing the memory that it has allocated and setting any remembered pointers to null?
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2019-04-08 21:16:45]
User972768 - Posts: 166
Yep. I follow template from ACSIL Programming Concepts: Allocating Memory for Classes

Just noticed one more case. Everything is working fine: charts get their updates, study draws perfectly fine. Then I decide to save and close chartbook. Same popup comes up.

There is definitely something wrong in my study in the area of memory management. I hope you can shed some light if I'm missing something in my Visual Studio C++ configuration that could manifest itself like this.

PS I use std::list and the only place where I really release memory is via "delete my_list" after sc.LastCallToFunction call as shown in the template

Thanks a lot and best regards
[2021-05-10 12:03:39]
User562525 - Posts: 32
There is a big problem. When doing RELEASE_ALL_DLLS over UDP, the sc.LastCallToFunction does NOT get called! Obviously this is a bug and looks like Sierra has been avoiding fixing it since 2 years ago on this thread. Stop avoiding bugs. Please fix it.
[2021-05-10 13:37:33]
Sierra Chart Engineering - Posts: 104368
Okay we will look at implementing support for indicating the last call to the study, when the DLL is unloaded.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2021-05-10 13:37:53

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account