10-29-2024 06:54 AM - edited 10-29-2024 07:49 AM
@nottilie wrote:
At the prgram start you need to create this client and use it for all your PLC reads.
In your case you open about 30 TCADSclients and run the loop in 10ms timing.
But it is not possible to run all this code in 10ms as connection to the PLC needs longer. And you connect about 30times per loop iteration without closing the .NET references.
It will be really hard to fix this existing program so it is running as the fundament is not perfect.
My suggestion once more is
Open the ADSconnection once before you enter the continous run loop.
Prepare all your needed readers and writers at the beginning.
Reuse all reusable references to the .NET objects without new creation.
If you need to create new the close the unneeded.
Read and write your needed data inside the loop. (ideally with a good timing)
Close the ADS connection when you close the program.
This is the schematic which needs a few hours to implement and then a few days to fix the problems 😉
So I think, for me this is not solvable, due to the lack of knowledge of this programm?
Still makes me think, how this problem could run without problems in the past? But as I am told, it did.. 😞
Edit:
In our files i've found a printed manual for implementing TWINCAT ADS .NET in Labview from an site called infosys.beckhoff.com/content and the programm is just the way it is described in the manual.
10-29-2024 07:35 AM
@Credible wrote:
@nottilie wrote:
At the prgram start you need to create this client and use it for all your PLC reads.
In your case you open about 30 TCADSclients and run the loop in 10ms timing.
But it is not possible to run all this code in 10ms as connection to the PLC needs longer. And you connect about 30times per loop iteration without closing the .NET references.
It will be really hard to fix this existing program so it is running as the fundament is not perfect.
My suggestion once more is
Open the ADSconnection once before you enter the continous run loop.
Prepare all your needed readers and writers at the beginning.
Reuse all reusable references to the .NET objects without new creation.
If you need to create new the close the unneeded.
Read and write your needed data inside the loop. (ideally with a good timing)
Close the ADS connection when you close the program.
This is the schematic which needs a few hours to implement and then a few days to fix the problems 😉
So I think, for me this is not solvable, due to the lack of knowledge of this programm?
Still makes me think, how this problem could run without problems in the past? But as I am told, it did.. 😞
You can fix it, but it will require some refactoring. If it were easy, the previous person wouldn't have left it like this. 🙂
10-29-2024 07:51 AM
@Yamaeda wrote:
You can fix it, but it will require some refactoring. If it were easy, the previous person wouldn't have left it like this. 🙂
The problem is, I dindnt even understand the proposed steps before.
10-29-2024 08:01 AM
@Credible wrote:I guess the ".NET calls" are all the TcAdsClient blocks in the sub vi? Again, I am total new to this. How could I close the .NET references.
There is a function called "Close Reference". You just use that to close the .NET reference after the Dispose method call.
A reference actually uses next to nothing as far as memory is concerned. However, there is a limit to the number of references that can be opened. I don't remember the exact number, but it was something weird. When that limit is reached, it is flagged as an out of memory error. When you close the reference, to stop the ever-growing number of open references.
10-29-2024 11:21 AM
@Credible wrote:
So I think, for me this is not solvable, due to the lack of knowledge of this programm?
Still makes me think, how this problem could run without problems in the past? But as I am told, it did.. 😞
Before as in on an older computer? Could it be that the earlier mistakes simply compound faster?
10-29-2024 11:27 AM
@Yamaeda wrote:
@Credible wrote:
So I think, for me this is not solvable, due to the lack of knowledge of this programm?
Still makes me think, how this problem could run without problems in the past? But as I am told, it did.. 😞
Before as in on an older computer? Could it be that the earlier mistakes simply compound faster?
No, its the very same system.
10-29-2024 05:34 PM
@crossrulz wrote:
@Credible wrote:I guess the ".NET calls" are all the TcAdsClient blocks in the sub vi? Again, I am total new to this. How could I close the .NET references.There is a function called "Close Reference". You just use that to close the .NET reference after the Dispose method call.
A reference actually uses next to nothing as far as memory is concerned. However, there is a limit to the number of references that can be opened. I don't remember the exact number, but it was something weird. When that limit is reached, it is flagged as an out of memory error. When you close the reference, to stop the ever-growing number of open references.
It's 2^20, just over a million (1,048,576).
10-30-2024 02:11 AM
As an addition.
You also need to close the references for ADSStream constuctor and ADSbinarywriter. Not only the one of ADSclient.
As theses are also continously opened references.
From my calculations if you keep them opened and we assume 30 ADScalls in each loop iteration with 3 opened references the program starts to crash after approx. 35000 loop iterations.