Metatrader 5 - 循环播放图表中的符号时占用大量内存 - 页 2

 
gr101:

我把它放在Windows Server 12 R2上,这也把内存推高了。

让我监测一段时间,并在这个线程上给出反馈。

它目前是650Mb

我没有改变任何东西,只是让它继续运行。

 
gr101:

谢谢你的反馈。

我想我将升级到Windows 10,看看是否会有不同。

你专注于循环。你在你的EA中还使用了什么?图形控制 或任何其他控制?
 

主题中早先的那个脚本是完整的EA(ForumQuestion1.mq5),它是将内存推高的原因。EA中没有其他动作。

没有图形控制

 

你好,阿兰。

请看所附的word文档。这是一个在Windows Azure中运行的Windows Server 2012 R2实例。这是一台新机器(所以没有有趣的软件或任何东西),它运行在西欧的数据中心。

在运行ForumQuestion1.mq5脚本时,使用内存随时间增加的情况也发生在这里(在本主题的早期)。

以下是随着时间的推移,从上午8:40到下午14:05,它从74.1MB增加到379.9MB的细分。

8:40 am

74.1 MB

刚刚开始的ForumQuestion1 EA

9:53 am

281.6 MB

10:30 am

297.2 MB

11:23 am

319.3 MB

12:23pm

343.5 MB

下午13:00

369.1 MB

下午14:05

379.9 MB

附加的文件:
 
我想这是正常的。我的MT4现在是1GB的内存。
 
Daniela Bluemel:
我想这是正常的。我的MT4现在是1GB的内存。
这个话题是关于MT5 Daniela的。
 
Alain Verleyen:
这个话题是关于MT5的,Daniela。
是的,我知道,但我的MT4也有同样的行为。
 
找到了一个解决方法......它不漂亮,但它可以工作。

解决方案。运行一个检查 内存的PowerShell脚本。当它超过60%时,就重新启动MetaTrader。

脚本在下面,我正忙着测试它。

步骤。

  1. 在Windows上点击开始
  2. 输入 "PowerShell ISE"
  3. 将下面的脚本剪切并粘贴到文本编辑器中
  4. 按下播放键(或者保存为PS1文件并从命令提示符中运行,但我仍在测试,所以暂时从PowerShell ISE运行它)

脚本如下:如果内存超过300MB(根据任务管理器中的内存栏),则重新启动Metatrader(终端64)。

#################################################################

strict-mode 
cls
$memoryThresholdInKiloBytes = 300000
$cooldownSeconds = 30
$loopPauseInSeconds = 30
$counter = 0

while($true){
    if($counter -gt 1000){
        cls
    }
    
    #write-host "$(get-date) Checking memory in use... counter=$counter"
    $processPrivateSet = Get-Counter "\Process(terminal64)\Working Set - Private"
    $wsPrivateKiloBytes = $processPrivateSet.CounterSamples[0].CookedValue / 1KB
   
    $memoryLabel = $wsPrivateKiloBytes.ToString('## ### ###') + " K"

    write-host "$(get-date) Kilo Bytes in use $memoryLabel"
    if($wsPrivateKiloBytes -gt $memoryThresholdInKiloBytes){
            
        write-host "$(get-date) Over threshold of $memoryLabel closing metatrader"
        
        # Close metatrader (terminal64)
        Get-Process terminal64 | Foreach-Object { 
            $_.CloseMainWindow() | Out-Null 
        } | stop-process –force
        
        # Give time to shutdown        
        write-host "$(get-date) Shutting down cooldown of $cooldownSeconds seconds #####################"
        start-sleep -Seconds $cooldownSeconds

        # Open metatrader
        write-host "$(get-date) Opening metatrader again and wait $cooldownSeconds seconds"
        &"C:\Program Files\MetaTrader 5\terminal64.exe"     
        start-sleep $cooldownSeconds
    }

    start-sleep -Seconds $loopPauseInSeconds
    $counter = $counter + 1;
}

# Links
# http://stackoverflow.com/questions/33344611/get-memory-private-working-set-of-process
 

你是否尝试过用 TerminalInfoInteger(..)来设置TERMINAL_MAXBARS 到一个合理的小值?

除此以外,你还有。

Terminal_memory_physical

系统中的物理内存,Mb

int

Terminal_memory_total

终端进程可用的内存,Mb

int

终端_内存_可用

终端进程的可用内存,Mb

int

终端_内存_使用

终端使用的内存,Mb

int


检查 问题的关键在哪里。

 

我的意见是,你光靠 "删除符号 "是无法释放内存的。

试试这个。

delete symbols;
symbols=NULL;