Mostly though, I'd like to know if the memory returned by Orders needs to be freed in my DLL (if I don't return that string to TradeStation) or if I should possibly use a different argument than SetAllocReturnString(1) so I don't need to free the memory. I tried calling free() on this string and threw an exception.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Memory returned by NTDIRECT.DLL Orders, and use of SetAllocReturnString arguments
Collapse
X
-
Memory returned by NTDIRECT.DLL Orders, and use of SetAllocReturnString arguments
I'm calling SetAllocReturnString and SetMaxReturnStringLength from a DLL and would like to know what the arguments to SetAllocReturnString do.
Mostly though, I'd like to know if the memory returned by Orders needs to be freed in my DLL (if I don't return that string to TradeStation) or if I should possibly use a different argument than SetAllocReturnString(1) so I don't need to free the memory. I tried calling free() on this string and threw an exception.Tags: None
-
Hello douggreen,
Thank you for your post.
SetAllocReturnString() parameters are as follows:
0 = string is written to a static buffer, overwriting any previous string at this buffer
1 = a new memory buffer is allocated for each returned string
TS may try to free the memory for strings returned from the NTDirect dll. Note, the wrapper NT functions in the ELD file will set SetAllocReturnString for you. If you need to set it manually for some reason though, you would want to use SetAllocReturnString(1) in case TS tries to free it.
If you are using the DLL outside of TS and are using SetAllocReturnString(1), you would be expected to free the memory in your code or else you will introduce a memory leak as NTDirect.dll will not take care of these dynamic memory buffers. It may be more ideal to use the 0 parameter in this case.
Please see this forum post for a full description of the function and how the string memory buffers are managed: http://www.ninjatrader.com/support/f...ad.php?t=39988 .
Please let me know if I can assist any further.DexterNinjaTrader Customer Service
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by DannyP96, 05-18-2026, 02:38 PM
|
1 response
27 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 05-11-2026, 05:56 AM
|
0 responses
117 views
0 likes
|
Last Post
by CarlTrading
05-11-2026, 05:56 AM
|
||
|
Started by CarlTrading, 05-10-2026, 08:12 PM
|
0 responses
69 views
0 likes
|
Last Post
by CarlTrading
05-10-2026, 08:12 PM
|
||
|
Started by Hwop38, 05-04-2026, 07:02 PM
|
0 responses
226 views
0 likes
|
Last Post
by Hwop38
05-04-2026, 07:02 PM
|
||
|
Started by CaptainJack, 04-24-2026, 11:07 PM
|
0 responses
417 views
0 likes
|
Last Post
by CaptainJack
04-24-2026, 11:07 PM
|

Comment