[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory error: EXE code too large ???



PureBytes Links

Trading Reference Links

Omega Man wrote:
> One of the keys to reducing the size of your EasyLanguage
> executable (and avoiding the need to write a dll) is reducing the
> number of inputs and variables you use.  Where possible, use fixed
> numbers in place of inputs 

This will reduce your EXE size slightly.

> and use the built-in variables (Value1,
> Value2, ...) in place of user-declared variables.  

This WILL NOT.

You can see exactly how changes influence your EXE size by looking at 
the TOK file for your study.  I don't think you can guess the final 
size of the EXE, but you can tell what changes the size.

To find the appropriate TOK file:  verify your study, open a DOS 
window, and type:

  cd \omega\ts           (or wherever your OMEGA directory is)
  dir /o:-d *.tok | more

The first TOK file (ignoring ERRORS.TOK) is the most recently-changed 
file, so that should be the TOK file for your study.  Let's say your 
file is S0310.TOK.  Now you can make changes to your study and see 
how much, if any, it changes the size by running "DIR S0310.TOK".

Here are the results of a few experiments:

1. One-line system containing the line "buy;":  379 bytes.
2. Add comments:   NO CHANGE
3. Add code containing value1, value2, value3:  1446 bytes.
4. Replace valueX with NAMED variables:  NO CHANGE
5. Replace named vars with inputs:  1692

As you can see, comments and named variables are "free."  They DO NOT 
increase your EXE size AT ALL, yet they greatly increase the 
readability of your program.  Also, by using named variables you 
don't introduce bugs by accidentally typing "Value21" instead of 
"Value12" or something like that.  In my opinion there is no reason 
to EVER use ValueX variables, other than tiny throw-away examples -- 
they just make your code harder to read and more error-prone.


Moving code from your study into a function will reduce the size of 
your TOK file, because it only shows the size of the system or 
indicator that you removed the code from.  It WILL NOT necessarily 
reduce the size of your overall system or indicator.  In fact if the 
code appears only once in your code, your EXE will get *bigger* if 
you move the code into a function, due to the function-call overhead, 
parameter passing, etc.

If the same code appears 2 or 3 times in your study, then you will 
probably save space by moving it into a function.  E.g. if you have a 
5-line sequence that appears 3 times, you might save space by moving 
those 3 occurences into a function.  If you have a 10-line sequence, 
you'll probably save space if it appears only twice in your study.  
You'll just have to try it and see if the EXE fits.

However, remember that functions won't have access to all the local 
variables in your study.  You'll have to pass everything in.  And you 
won't be able to *CHANGE* the variables in your study, other than by 
using the single return value of the function.  That might make it 
tough to move the code into a function.

Gary