No announcement yet.

High memory usage

  • Filter
  • Time
  • Show
Clear All
new posts

  • High memory usage

    With time my MT4 instance I'm running Simpletrader EA on starts using huge amounts of memory. It seems to be a recent development, perhaps a few weeks old. I've just noticed huge amounts of emails alerting me to high memory usage and I went to my VPS to check it out. It was up to 400MB. It gets that high within a day. Has anybody had any such problems? I'm not positive it's Simpletrader EA but not sure what else it could be, I'm only having problems with the one MT4 that's running Simpletrader.

  • #2
    This is sadly down to how MT4 work - there is an update coming out by Metaquotes soon that is going to fix any memory leak issues.

    Our advise is to reboot MT4 weekly.


    • #3
      Originally posted by WillT View Post
      This is sadly down to how MT4 work - there is an update coming out by Metaquotes soon that is going to fix any memory leak issues.

      Our advise is to reboot MT4 weekly.

      I'm restarting weekly but recently it doesn't help anymore. It gets too high within a day.


      • #4
        When you say to high - it will always use a fair amount of memory to begin with, but it shouldn't grow that quickly.

        1.9 will be slightly better on memory usage, but it will still leak (1.9 will be released in a few more days - just making some final adjustments to it)


        • #5
          I just spotted my LMAX instance was 800 MB (yes 8 HUNDRED). I have not restarted for a while and on restart it was the normal 50MB or so. I run 3 other MT4 instances in the same VPS (Windows 2003) and they are still the same size - and they were restarted a few weeks ago as well - i do not restart unless i need to in general and have not generally needed to unless MT4 pushes out an update. I cannot tell you how long it took to get so high but i will monitor from now on. I am running v1.72


          • #6
            BTW i also have my own (home written) EA that blocks on a network socket with a small timeout to allow it to heartbeat - this runs in ALL my MT4 instances - i use it to trade manually across all my MT4 instances. It operates in the same manner a copier would so i would expect it to suffer the same problems a copier would if it was a general MT4 problem- but it DOES NOT!

            My conclusion is that it is NOT a general MT4 problem


            • #7
              I can confirm that as soon as you see version 2 of the EA then you'll know MT4 has rolled out the MAJOR update. And this has some very very nice features including super fast execution vs current.


              • #8
                I have restarted yesterday evening, this morning it was up to 170MB already (that's when I get a warning first) and now 5 hours later it was up to 200MB.

                Is it possible we get more leaking if there are more positions open? I did not have these problems earlier.


                • #9
                  Just did a quick test:
                  Started EA a while ago
                  11.26 22:14 17.5 97.7 MB
                  11.27 00:42 32.9 106.7 MB
                  11.27 11:46 87.0 157.4 MB

                  I then stopped the EA a few hour ago ..
                  11.27 18:16 32.9 83.1 MB

                  Lets see what it is doing tomorrow without the EA running


                  • #10
                    MT4 does not memory leak on its own.

                    Any EA that uses recursion (i.e. an infinite loop) will memory leak. The reason for this is that the current MT4 cannot handle recursive loops properly. The NEW version of MT4 CAN handle this, and as such will stop memory leaking.

                    Nothing we can do about this I'm afraid as it stands.


                    • #11
                      Did you hear what i said earlier - i have WRITTEN an EA PERSONALLY which has a similar core to any decent blocking copier. It BLOCKS on a network socket so can respond to client request IMMEDIATELY (<1ms roundtrip to client) and times out every 100ms in order to poll for feed and/or order changes, heartbeat etc. It runs full time and has done for 9-12 months. It loops continuously (ie is NOT tick driven)

                      If a faster feed was required then another EA could be responsible for emitting feed updates on tick - but i did not find that necessary - 1 EA suffices for my needs

                      IT DOES NOT LEAK - i can run my EA for weeks with no perceptible leakage attributed to the EA


                      • #12
                        Perhaps i should point out that the tick updates are stalled when the EA is looping - once the EA has been kicked off by the first tick - and like your EA its does not respond well to attempt to modify parameters as the thread dedicated to the EA/chart is busy looping and it blocks the GUI from accessing the EA parameters - i have to check the busy flag to see if EA's have been stopped to terminate the loop - familiar ?

                        I can (and do) run multiple EA instances in a single MT4 instance, so its clear that it uses 1 thread per chart/EA (but not indicator - that uses a shared thread i believe)


                        • #13
                          Yes I'm aware of the ability to basically fake a tick. and as such run it as fast as you like however this requires external functionality that *could* have been removed come an MT4 update, so instead using recursion which would never be removed was the best idea.

                          Alongside that, at the time recursion didn't appear to mem leak (it does over time). The reason for instant high memory usage is the fact there is a large stacksize specified.

                          Its all relatively irrelevant now as the new MT4 build has a load of new features which fix recursion issues.


                          • #14
                            I understand the principle of generating false ticks - i use it myself in something else to improve the responsiveness of a system in low liquidity (posting the windows message to a chart - in my case from a script)

                            I understand what recursion is - calling oneself from oneself on the same thread - by that can i assume you are generating the windows message from the EA itself - synchronously (or you are calling start from withing start - eek!) - therefore increasing the call stack each time. This sounds dangerous as not only will it lead the the stack expanding for each tick but may lead to instability in the process itself as i would expect the call stack is a finite resource not necessarily tied to memory availability (not i cannot say authoritatively)

                            In my case i move most of the processing into a subservient method and simply call that method repeatedly in a blocking network loop - voila - no recursion - no leak !

                            My point is that it is possible to NOT LEAK NOW - you don't need to wait until the next version of MT4 - meanwhile your client are suffering NOW with something that can crash the MT4 and/or VPS if they do not take care.


                            • #15
                              We have thousands of users on this current EA so rolling out new software is always a relatively heavy task. You can run for months and months before running into issues with the current EA, however we normally suggest users simply restart their MT4 on a weekly basis. So there is no urgent need to roll out a new version especially when the new version of MT4 is literally weeks from being released.

                              Releasing software to such a vast number of users over a huge different number of brokers requires time and testing. If we weigh it up, it seems pointless to rewrite the current EA.

                              We do not constantly recall start();

                              I appreciate your comments though - good to see.