Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

Memory leak using PHP?

More
11 Sep 2010 13:27 #71 by steveh
Replied by steveh on topic Re: Memory leak using PHP?
Thanks very much for doing the work. I suspected that the version of PHP was a strong candidate. There is a lot of noise on the forums about memory leaks prior to 5.2.x.I spent a couple of hours today going over the PHP version migration documents, change logs, and backwards incompatabilities, and there are a few between 5.0.5 and 5.2.12 that could solve the problem, one specifically for foreach. There doesnt appear to enormous code heartache in migrating from 5.0.5 to 5.3.x, except in the winapi and date areas, but these should be straightforward enough.My dread relates to the need to upgrade 100+ machines out in the world. That will be very uncomfortable.On Monday I am going on a trip for 2 weeks so will be silent for a bit. When I get back I will do a test update and see how it goes. I will let you know how it all works out if you are interested. If all goes well I will want a development plus unlimited licence from you. Your timely and effective support has sold me.Thanks again.

Please Log in or Create an account to join the conversation.

More
11 Sep 2010 13:07 #70 by support
Replied by support on topic Re: Memory leak using PHP?
Thanks for your analysis. I have first run your opc2.php script under PHP 5.2.12, which is what is on my test machine. No leak - see this video: php 5.2.12-no leak.wmv. There are some memory fluctuations, but no ever-increasing consumption, neither in eopcdal.exe nor in php.exe.
I then installed PHP 5.0.5, and was able to reproduce the problem as you have described it. The problem seems to be related to the foreach statement.
Considering that there is also no leak when called from other tools, my conclusion is that this is PHP 5.0.5 problem. I know this is not going to make you happy, but the facts are clear.
BTW, I have enabled .WMV file upload for the site and increased file size limit for forum attachments; your video is here: opc2.wmv .
Best regards,
Zbynek Zahradnik

Please Log in or Create an account to join the conversation.

More
11 Sep 2010 07:18 #69 by steveh
Replied by steveh on topic Re: Memory leak using PHP?
I have created a simple PHP CLI script to show the problem and have uploaded it here.

I also created a video of the effect, but could not upload it here. The video can be found at pozzie.net/images/opc2.wmv .

Please Log in or Create an account to join the conversation.

More
10 Sep 2010 23:39 #68 by steveh
Replied by steveh on topic Re: Memory leak using PHP?
I have considered subscriptions, but I have not yet worked out how to do it in PHP.

Please Log in or Create an account to join the conversation.

More
10 Sep 2010 23:37 #67 by steveh
Replied by steveh on topic Re: Memory leak using PHP?
PHP version is 5.0.5 and Zend engine is 2.0.4. This combination has been running complex long lived PHP apps for me for quite a while with no dramas. I do hope this isnt soley a PHP problem, as upgrading the versions would be a real nuisance.

Please Log in or Create an account to join the conversation.

More
10 Sep 2010 16:28 #66 by support
Replied by support on topic Re: Memory leak using PHP?
First test seems to indicate that this may indeed be PHP-related. I have written an equivalent VBScript code, and no apparent leak can be seen. Will try PHP later.

Please Log in or Create an account to join the conversation.

More
10 Sep 2010 16:18 #65 by support
Replied by support on topic Re: Memory leak using PHP?
This is weird, and may have to do with the way PHP manages lifetime of COM objects. I will try to reproduce here. Which version of PHP are you using?
BTW, if your application is long-running, consider subscribing to item changes, instead of calling the Read repeatedly.

Please Log in or Create an account to join the conversation.

More
10 Sep 2010 15:24 #64 by steveh
I am evaluating the EasyOPC-DA COM in a PHP environment. The script I am running in CLI simply opens a new instance:$client =new COM("OPCLabs.EasyDAClient.5.0");then sets up a variant array of 29 value ids:$ids = new VARIANT(array of value id strings);and then reads the values from the OPC server every 1/2 second in an infinite loop:$results = $client->ReadMultipleItems("", OPCServerName, $ids);Doing this all is well behaved. Now here is the bizzare part. If I add the line:foreach ($results as $X) { };after the ReadMultipleItems within the infinite loop the eopcdal.exe process starts to use ever increasing memory, and its cpu usage percentage also starts to increase, and even more bizzarely, the calling PHP script also starts to use more memory and cpu percentage. I have tried this with eopcdal.exe operating as a local server and as a service, and the behaviour remains the same and 100% repeatable.If I add something like:$result = strtok($X->Vtq->ToString(),' ');within the { } of the foreach then it seems like the increases gain in rate.If left running eventually the cpu goes to 100% and an error is thrown with no error type statement.I am certain I am not imagining this, and I am also certain I have no idea what to try next.Any ideas appreciated.

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.072 seconds