Abnormal program termination

Back to topics list  | 1 2 To post a new topic, please log in or register
abiank 2010.10.08 11:19 #

If you're using a shared data segment _and_ running on two instruments at once sooner or later there will be two ticks on the two instruments spaced so closely that they will have a conflict while accessing the shared segments, since two EAs live in two different threads.

As a quick workaround, try making a copy of the dll, and having each EA load a separate copy. 

7bit 2010.10.09 16:52 #

As a quick workaround, try making a copy of the dll, and having each EA load a separate copy.

Simply never using any global variables in the dll at all would completely fix this problem.

Pass everything the dll function needs as function arguments to it on every call and keep all globals that are needed in the mql4 code. This is a generally recommended best practice (also try to follow the same principle in your mql4 code, try to avoid globals as if they were spawns of the devil (which they really are) and pass everything a function needs always as function arguments). This will nicely decouple your functions from each other and helps avoiding many nasty problems and potentially difficult to find bugs.

helsywarner 2015.03.30 09:13 #

Stack is used for static memory allocation and Heap for dynamic memory allocation, both stored in the computer's RAM .

Variables allocated on the stack are stored directly to the memory and access to this memory is very fast, and it's allocation is dealt with when the program is compiled. When a function or a method calls another function which in turns calls another function etc., the execution of all those functions remains suspended until the very last function returns its value. The stack is always reserved in a LIFO order, the most recently reserved block is always the next block to be freed. This makes it really simple to keep track of the stack, freeing a block from the stack is nothing more than adjusting one pointer. More about ........ Stack and Heap



Back to topics list   | 1 2  

To add comments, please log in or register