我们有一个项目最初是用 4022.29 制作的。我们还尝试使用 TwinCAT 4024.x 运行该项目。当配置在我的本地计算机上首次激活时,它运行良好。但是,当我重新启动项目或激活配置时,我收到以下错误消息:
Error 27.08.2019 14:06:37 322 ms | 'Port_851' (851): PLC: PLC instance xxx Instance tried to free pointer 0xffff9e02fe620bd8 which was not allocated by the PLC instance.
Error 27.08.2019 14:06:37 322 ms | 'Port_851' (851): PLC: PLC instance xxx Instance tried to free pointer 0xffff9e02fe620b48 which was not allocated by the PLC instance.
… (~20 more error messages)
Error 27.08.2019 14:06:37 322 ms | 'Port_851' (851): PLC: PLC instance xxx Instance tried to free pointer 0xffff9e02fe61fe28 which was not allocated by the PLC instance.
Error 27.08.2019 14:06:37 322 ms | 'Port_851' (851): PLC: PLC instance xxx Instance did not free dynamically allocated memory block at address 0xffff9e02fe616878 of size 65.
Error 27.08.2019 14:06:37 322 ms | 'Port_851' (851): PLC: PLC instance xxx Instance did not free dynamically allocated memory block at address 0xffff9e02fe6167d8 of size 65.
… (~20 more error messages)
Error 27.08.2019 14:06:37 322 ms | 'Port_851' (851): PLC: PLC instance xxx Instance did not free dynamically allocated memory block at address 0xffff9e02fe615978 of size 55.
什么原因导致这些错误消息?他们为什么突然出现?我应该摆脱它们吗?如果是,我该怎么做?
最佳答案
部分答案
这个答案需要一些改进/更好的理解。我将其发布在这里以收集有关解决方案的一些信息。
来源
倍福支持:
The error messages you receive lead to dynamically allocated memory in the router memory (such as __new() ) or not released interface pointers.
The mentioned error messages were implemented with the 4024 release. In the older versions of TwinCAT we were not able to detect such a memory lack.
我如何摆脱它们
由于缺乏理解,我不太确定如何用自己的话表达以上内容。不过,我确实追踪到了我们项目中错误消息的来源。
二分查找
我所做的是使用binary search追查问题的根源。首先,我不断禁用项目的一半事件任务,直到错误消息消失。然后我重新启用任务,直到找到导致问题的特定任务。之后我对此任务中运行的代码执行了相同的操作。启用/禁用剩余的 50% 以追踪导致问题的代码。
来源
最后我找到了一个使用其他功能 block 作为输入的功能 block 。当我更改输入时
VAR_INPUT
fbSomeFb : FB_SomeFB;
END_VAR
进入
VAR_INPUT
fbSomeFb : REFERENCE TO FB_SomeFB;
END_VAR
项目重新启动后,错误消息消失。
修复了另一个问题
消除这些错误消息后,这个特定项目的另一个问题得到了解决。当我们激活配置或进入配置模式时,我们总是遇到 PLC 崩溃并重新启动的问题。这仅发生在机器 PLC 上(不是我们开发的任何 PLC)。
关于twincat - 是什么导致 Twincat 4024 中出现动态分配的错误消息以及如何消除它们?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68709572/