Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Bug Reports
 PowerHome Messageboard : PowerHome Bug Reports
Subject Topic: Memory Leak in 2.1.4? Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
scottmi1
Groupie
Groupie
Avatar

Joined: July 11 2006
Location: United States
Online Status: Offline
Posts: 60
Posted: November 27 2011 at 08:13 | IP Logged Quote scottmi1

I finally got around to trying the 2.1.4 version earlier this week. I installed 2.1.2 and applied 2.1.4 over it. The process went smoothly and everything was working as expected.

However, 2 days later Powerhome seemed very sluggish and then I saw a message that Windows wanted to increase virtual memory, so I took a look at Windows Task Manager and was surprised to see that Powerhome was using over 620k of memory. I shut down Powerhome and restarted it and saw it was now using only 25k of memory. Checked it 30 minutes later and it's now up to 50k.

I have a pretty modest setup. I'm running on XP Pro SP3 and am using both a PLC and a CM11 for controllers. The only plugin I'm running is Filemon. I do have 2 macros that run continuously to monitor a CAI Webcontrol board.

I've looked over the threads for 2.1.x and haven't seen any mention of memory leaks. Have I overlooked something in the install that could be causing this or is this a bug in 2.1.4?

Mike..
Back to Top View scottmi1's Profile Search for other posts by scottmi1
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: November 27 2011 at 10:00 | IP Logged Quote BeachBum

We did a lot of testing for memory leaks a while back and concluded there was no evidence of any. One of the biggest factors to an increase is the Event Log. Usually you see it increase the size of the data base but that could also translate to memory usage. I find a very effective tool for analyzing is Process Explorer. My system shows 204,756K of private and 189,620K working set.

__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
scottmi1
Groupie
Groupie
Avatar

Joined: July 11 2006
Location: United States
Online Status: Offline
Posts: 60
Posted: November 27 2011 at 12:48 | IP Logged Quote scottmi1

I have no idea what's going on with this. In the 4.5 hours since I restarted Powerhome, the memory use reported in Task Manager has gone from 25k to 228k and it just continues to increase. I just downloaded Process Explorer and it's currently showing private bytes of 234k and working set of 230k. Strike that, in the course of writing this it's gone to 238k and 236k.

My 2.1b system was very stable. Looks like I need to return to it for now.

Mike..
Back to Top View scottmi1's Profile Search for other posts by scottmi1
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: November 27 2011 at 13:52 | IP Logged Quote BeachBum

Weird… Are there any macros running or is the system idle. Do you have CPU usage at the same time? Double click PH in Process Explore and click on Performance. See what that is saying. You’ll get a lot more detail in that window.

__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
scottmi1
Groupie
Groupie
Avatar

Joined: July 11 2006
Location: United States
Online Status: Offline
Posts: 60
Posted: November 27 2011 at 14:05 | IP Logged Quote scottmi1

CPU looked normal with 2.1.4. However, I've now gone back to 2.1b. FWIW, Process Explorer is now reporting Private Bytes of 20K and Working set of 30K and both are holding steady.

Mike..
Back to Top View scottmi1's Profile Search for other posts by scottmi1
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: November 27 2011 at 15:41 | IP Logged Quote BeachBum

I was hoping we might get closer to it. Something was doing a type of Get Main over and over again and it must have been inside of PH but as far as I know there have been no reported problems of this nature going on. Usually it’s a repetitive thing in a macro. But I’m with you, why 214. I am assuming you took all the defaults and installed in the root of C: not program files. I don’t think it would have been a problem since you’re on XP. I’ve run 214, same database, onWin7, Vista and XP SP3 with no noticeable difference except Vista is slower. Hopefully you can go back and test as in bring up PH without anything running and see what triggers the grabbing of memory.

__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
scottmi1
Groupie
Groupie
Avatar

Joined: July 11 2006
Location: United States
Online Status: Offline
Posts: 60
Posted: November 27 2011 at 16:01 | IP Logged Quote scottmi1

I did take the defaults and installed it in the root. Hopefully I'll have a chance later this week to go back and give it another go. I do have a couple of macros that run continuously (i.e. they run, wait for 10 seconds, run, wait, etc.) so next time I'll try it without the macros and see if it makes a difference.

Thanks for your help,

Mike..
Back to Top View scottmi1's Profile Search for other posts by scottmi1
 
scottmi1
Groupie
Groupie
Avatar

Joined: July 11 2006
Location: United States
Online Status: Offline
Posts: 60
Posted: November 30 2011 at 16:53 | IP Logged Quote scottmi1

OK, I had a chance to play with this some more today and have some further observations. The incremental memory increases appear to be caused by 2 macros that run constantly.

When I run 2.1.4 without the macros, the powerhome.exe memory stays fairly constant at about 29,000K. When I start the first macro, READ_ANALOG_INPUTS, the memory increases by about 48K each time it loops every ten seconds. When I start the second macro, READ_DIGITAL_INPUTS, the memory increases by about 96K for every iteration, which also occurs every 10 seconds. The 2 macros are used to read the inputs on my WebControl board and update virtual analog and digital inputs.

The READ_ANALOG_INPUTS macro consists of a formula that invokes the ph_geturl function followed by a series of formulas that invoke the ph_setanalogout function, then a WAIT for 10 seconds, at which point it loops back to the beginning. All formulas are set for immediate execution

The READ_DIGITAL_INPUTS macro is similar. It consists of a series of formulas that invoke the ph_setdigitalout function (which have the ph_geturl imbedded in the function), then it WAITs for 10 seconds and loops back to the beginning. Again all formulas are set for immediate execution.

I didn't have this problem in 2.1b. Any thoughts on what might have changed in 2.1.4 to cause this?

Mike..
Back to Top View scottmi1's Profile Search for other posts by scottmi1
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: November 30 2011 at 19:25 | IP Logged Quote BeachBum

Are you inputting to a global, local or temp variable?

__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
scottmi1
Groupie
Groupie
Avatar

Joined: July 11 2006
Location: United States
Online Status: Offline
Posts: 60
Posted: November 30 2011 at 20:50 | IP Logged Quote scottmi1

I'm using a single local variable in one macro and no variables in the other.

Mike..
Back to Top View scottmi1's Profile Search for other posts by scottmi1
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: November 30 2011 at 21:35 | IP Logged Quote BeachBum

The reason why I asked if it was a global that stays in storage. So if I’ve got this right you’re inputting a ph_geturl into a local doing some stuff and the macro ends or do you call another from that one. To me it’s got the smell of a macro that doesn’t really go away and keeps getting more data. I know Dave is watching maybe he has a thought as to why it works on the old release but runs away on the new. I wonder what would happen if you cleared the variable as you exit and /or use an end macro to force it. Another thought is to use a timed event instead of the wait and see if that would break it up.

__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
scottmi1
Groupie
Groupie
Avatar

Joined: July 11 2006
Location: United States
Online Status: Offline
Posts: 60
Posted: December 01 2011 at 00:02 | IP Logged Quote scottmi1

Pete,

Thanks for hanging in there with me on this. As I said earlier one macro uses a local variable and the other macro does not use any variables at all, but both increase memory when they run. It seems more likely that it's related to one of the functions. This might not be noticed by others if the memory is being released when the macro ends, but I am seeing it since my macros keep repeating and never end. I will try and test that tomorrow by killing the macros after they've run for a while and seeing if the memory comes down.

I had thought about calling these macros from a timed event rather than using a wait and loop, but didn't know if I could or how to specify a frequency of less than a minute. Also, I like to see upcoming timed events in the System Status window and that would monopolize it with these 2 macros running every 10 seconds.

Actually, this may be a good application for the scrapeurl plugin, but until I can find the time to put that together, I need to figure this memory problem out so I can use 2.1.4.

Mike..
Back to Top View scottmi1's Profile Search for other posts by scottmi1
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: December 01 2011 at 00:32 | IP Logged Quote BeachBum

Well my theory is if the timed event works then Dave has something to work with in trying to figure why it worked on a back version but not on the current. He may have a glitch that didn’t show it’s self until now or you were getting away with something it was not designed to do. I would assume if you had a looping macro and you reloaded the variable it would reduce automatically but there may be other things that get queue and don’t release. I believe I saw somewhere you can do the offset in less than minutes like .5 instead of 1 in the timed event.

__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
scottmi1
Groupie
Groupie
Avatar

Joined: July 11 2006
Location: United States
Online Status: Offline
Posts: 60
Posted: December 01 2011 at 09:00 | IP Logged Quote scottmi1

Did some more testing. First, I tried killing the macros to see if memory would be released - nope. Then I disabled the loop on the macros and ran them one at a time. Memory use still increased each time I ran them and did not come back down.

I'm still guessing that the problem is related to the functions I'm invoking. Between the 2 macros I am using 3 functions - ph_geturl, ph_setanalogout and ph_setdigitalout. It seems unlikely the problem is with ph_geturl as it's so common and I'm sure you guys tested lots of macros that used it. My money is on the other 2 functions which are probably not too widely used and may not have been included in the leak tests.

I also tried to run the macros from a timed event, but it would not accept a decimal value for frequency, so I still don't know if or how I can specify a frequency of less than a minute.

Mike..

Edited by scottmi1 - December 01 2011 at 09:01
Back to Top View scottmi1's Profile Search for other posts by scottmi1
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: December 01 2011 at 09:30 | IP Logged Quote BeachBum

Mike, you’re right, I use the get url all the time. The other 2 I know nothing about. When Lee and I did leak testing we basically monitored our own system nothing fancy. If you want I might be able to test them on my system if you were to export then and send them to my e-mail address. The forum sometimes screws up the data. I do believe I hear Dave about to chime in…….

__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
scottmi1
Groupie
Groupie
Avatar

Joined: July 11 2006
Location: United States
Online Status: Offline
Posts: 60
Posted: December 01 2011 at 10:36 | IP Logged Quote scottmi1

Pete,

I've exported both macros. Let me know where to send them.

Also, I failed to mention one other function, ph_regexsnap, that is used only in the READ_ANALOG_INPUTS macro.

Mike..

Edited by scottmi1 - December 01 2011 at 13:52
Back to Top View scottmi1's Profile Search for other posts by scottmi1
 
BeachBum
Super User
Super User
Avatar

Joined: April 11 2007
Location: United States
Online Status: Offline
Posts: 1880
Posted: December 01 2011 at 15:56 | IP Logged Quote BeachBum

Sorry I took so long… Had other things to attend to. My address is under memberlist. I’ll PM you

__________________
Pete - X10 Oldie
Back to Top View BeachBum's Profile Search for other posts by BeachBum
 
scottmi1
Groupie
Groupie
Avatar

Joined: July 11 2006
Location: United States
Online Status: Offline
Posts: 60
Posted: December 01 2011 at 16:10 | IP Logged Quote scottmi1

Just sent them.

Thanks,

Mike..
Back to Top View scottmi1's Profile Search for other posts by scottmi1
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: December 01 2011 at 16:29 | IP Logged Quote dhoward

And here I am .

Ok, I looked into the code and the differences that
occurred between 2.1b and 2.1.4 and I suspect its the
ph_geturl function.

Just so I understand what you're doing, based upon the
previous messages, you've got a couple of macros that
loop on themselves with a wait statement. The macros
call the ph_geturl function to query a controller that PH
doesnt have support for, the returned HTML is scraped for
the appropriate values and ph_setanalogout and
ph_setdigitalout functions are used to update essentially
virtual devices controlled by the PowerHome Virtual
controller.

If thats basically the gist of it, then you should be ok
as long as the loop within the macro is via a Goto Label
or Jump statment rather than the macro actually calling
itself via the Macro command or a ph_macro function.

Also, there is no way to get a timed event to fire at
less than 1 minute intervals so the Wait technique should
be the best way.

The only thing in the above scenario that has changed
significantly between versions is the ph_geturl function
so this is why I suspect it. It should be easy enough to
test by just commenting out the line in the macro that
calls ph_geturl (and substituting fake data so the rest
of the function works) and see if the memory increase
stops.

The main thing that has changed is the socket control
that is used in the ph_geturl function. PowerHome
licenses socket controls from Catalyst and version 2.1.4
is using the version 6 of this control. Its possible
that this version of the control does not want to play
nice with your system. Ive seen situations where this
type of thing happens and for most people there is no
problem but a select few will get a memory leak. The
next beta of PowerHome should be upgraded to the newest
version of the Catalyst controls (version 7) so its
possible the problem will just go away with the next
beta.

However, 2.1.4 also includes a new version of the
ph_geturl function and it will eventually be depredated.
The new version is ph_geturl1 and takes 3 parameters vs
the 1 of ph_geturl. The first parameter is the url, the
second parameter is a number from 0 to 3 for the method
of performing the geturl function and the 3 parameter is
a timeout value in seconds.

If possible, I would like for you to update your macro
lines from

ph_geturl("your url here")

to

ph_geturl1("your url here",0,20)

This will essentially give you exactly the same
functionality of what is the the current (2.1.4) version
of ph_geturl. So you should still have the memory leak.
After that test, change the second parameter from 0 to 1.
This will actually change the Catalyst control that is
being used from a raw socket control to their version of
an http control. It may be possible that whatever
problem that is causing the leak is isolated to the raw
socket control and not all Catalyst controls. You can
also try the other parameters of 2 and 3 to see if they
have any effect as well. I didnt get a chance to
determine the detailed differences between method 1, 2,
and 3 but will look into it update this thread.

Let me know how it goes,

Thanks,

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
scottmi1
Groupie
Groupie
Avatar

Joined: July 11 2006
Location: United States
Online Status: Offline
Posts: 60
Posted: December 01 2011 at 17:04 | IP Logged Quote scottmi1

Dave,

Thanks for jumping in. You are correct that I am using a Goto Label and don't have the macro calling itself. I will go to work on your suggestions and let you know what I find out.

Mike..
Back to Top View scottmi1's Profile Search for other posts by scottmi1
 

Page of 2 Next >>
  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum