Author |
|
MrGibbage Super User
Joined: October 23 2006 Location: United States
Online Status: Offline Posts: 513
|
Posted: November 22 2012 at 08:34 | IP Logged
|
|
|
I noticed that one of my macros was having a problem today. I did some troubleshooting and found that the following
formula was giving an error
ph_geturl1( "{PHCA_SERVER}?username={PHCA_USER}&password={PHCA_PASS}&" + ph_getvar_s(2,10) + "=" +
ph_htmlescape(if(ph_getvar_s(2,3)="1","Motion Detected: ","Secure: ") + string(now())),1,20)
*ERROR* - 10012 Out Of Memory
I reinitialized and still got the error. I shut down PH and restarted it and the formula started working again.
My questions are:
Is there something inherently less than optimal about the formula I am using, and I should be looking for a more
efficient way of doing it?
Is there a way for me to trap errors such as this and notify me that something is amiss?
I have never gotten that error before, and my PH computer is running fine. No other errors or strangeness to lead me
to believe something was wrong with it. This is a relatively new macro that I am working on, so I can't say that it
has been working great for a long time and this just started happening. On the contrary, this is a new macro and I am
getting this error so I am wondering if I am just doing it wrong.
Skip
__________________ Skip
|
Back to Top |
|
|
MrGibbage Super User
Joined: October 23 2006 Location: United States
Online Status: Offline Posts: 513
|
Posted: November 24 2012 at 18:04 | IP Logged
|
|
|
Man, this is really causing me fits. I have now broke up the command into two steps
ph_setvar_s(2,1,"{PHCA_SERVER}?username={PHCA_USER}&password ={PHCA_PASS}&" + ph_getvar_s(2,10) + "=" +
ph_htmlescape(if(ph_getvar_s(2,3 )= "1","VIOLATED",string(today() ) ) ) )
and then
ph_geturl1( ph_getvar_s(2,1), 1, 20)
and I get the Out of Memory error on the ph_geturl1 command. PH runs fine for several hours and then out of the blue, I
start getting this error. So far, the only fix has been to actually restart PH.
Anyone have any suggestions? Is there some low-level debugging/trace I can run? I am thinking about passing the url to
curl.exe, but I would rather not if I could avoid it.
Skip
__________________ Skip
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: November 24 2012 at 20:04 | IP Logged
|
|
|
Just a wild thought but have you tried PHUPG against the DB? Sounds like a Sysbase thing to me.
Edited by BeachBum - November 24 2012 at 20:05
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
MrGibbage Super User
Joined: October 23 2006 Location: United States
Online Status: Offline Posts: 513
|
Posted: November 25 2012 at 10:33 | IP Logged
|
|
|
My database was 8MB and then I ran PHUPG which took it down
to 4MB. I'll let it run for a while and see if it keeps on
working. Crossing fingers.
__________________ Skip
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: November 26 2012 at 13:52 | IP Logged
|
|
|
Skip,
Looking at your formula, Im almost thinking that you're using a ph_geturl1 function within PowerHome to make a call to the internal PowerHome webserver. If so, this is probably not the best idea as it can cause problems with the internal queue's and such. Its hard to tell without know the value of [TEMP10].
If thats not it, then I would ask how much data does the URL actually return. Extremely large amounts of data being returned may cause an OOM error.
Depending upon what you're trying to accomplish, there may be a better way to write this. The URLSCRAPER plugin may be useful or perhaps retrieving data from the database via a SQL statement. I would need to have more details on what this code is trying to do.
Dave.
|
Back to Top |
|
|
MrGibbage Super User
Joined: October 23 2006 Location: United States
Online Status: Offline Posts: 513
|
Posted: November 26 2012 at 14:00 | IP Logged
|
|
|
Thanks, Dave. I ran the PHUPG utility yesterday and so far it is still running. As for your
ideas/questions...
This url is not the internal PH webserver. This is for my android app. The server is a google
app engine on appspot. In this case, no data is returned (just a 200/OK). It doesn't need to
return anything because all I am doing is telling the webserver to send the message to my
phone. In any case, TEMP10 just holds the ELK zone that just changed, such as FRONT_DOOR or
KITCHEN_MOTION.
__________________ Skip
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: November 26 2012 at 14:44 | IP Logged
|
|
|
Gotcha...that makes sense now (what you're doing with the function). Im not sure why you would ever get an OOM error on that then. Makes no sense. You're just making a call to an external server and passing data on the URL line and retrieving a 200/ok response. Not sure why the database would cause that issue either (8M isnt that big) but if its working now Im not going to complain .
Dave.
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: November 26 2012 at 14:56 | IP Logged
|
|
|
Dave, the reason I suggested the rebuild of the DB assuming it rebuilds any bad pointers, was I have seen in other DBs where a pointer would get overlaid and them memory gets eaten up. Don't know if that was the culprit or not but just a wild guess. If that was the case then the size would make no matter.
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
MrGibbage Super User
Joined: October 23 2006 Location: United States
Online Status: Offline Posts: 513
|
Posted: November 27 2012 at 19:34 | IP Logged
|
|
|
Well, I am sad to say I am getting the errors again. Other macros run fine. But this one, I get the OOM
every time it runs, unless I completely restart PH. Re-init isn't even good enough. I have not modified the
macro to call CURL.exe of using the ph_geturl1 command. Let's see how long it works. Dave, if there is
anything else that you want me to try in the interest of troubleshooting, I'm game.
__________________ Skip
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: November 27 2012 at 21:06 | IP Logged
|
|
|
Have you tried analyzing with Process Explorer? It might get you closer as to who is chewing up memory.
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
MrGibbage Super User
Joined: October 23 2006 Location: United States
Online Status: Offline Posts: 513
|
Posted: December 04 2012 at 19:31 | IP Logged
|
|
|
I haven't seen any smoking guns in Process Explorer. I have started using curl.exe to send the
command, and it is working fine, but it bugs me that I get a command window that pops for a
second or two while the command runs. Is there any way to make that not happen? I still want the
command to run, but I don't want to see the command window pop up. I hope that makes sense.
__________________ Skip
|
Back to Top |
|
|
MrGibbage Super User
Joined: October 23 2006 Location: United States
Online Status: Offline Posts: 513
|
Posted: December 04 2012 at 19:51 | IP Logged
|
|
|
Funny. It just happened again (started getting the OOM errors). I looked at
Process explorer a bit more and I did notice one thing. While PH was still in
the error state, it was taking up 77MB memory. But after restarting PH, it is
at only 32MB. I wonder if there is some sort of memory leak???
Anyway, I am still interested to hear if there is a way to keep the command
shell fro opening when running the external commands.
__________________ Skip
|
Back to Top |
|
|
BeachBum Super User
Joined: April 11 2007 Location: United States
Online Status: Offline Posts: 1880
|
Posted: December 04 2012 at 20:45 | IP Logged
|
|
|
Have you tried writing to file when running ph_geturl1( ph_getvar_s(2,1), 1, 20). Maybe at the instance when you get the OOM there might be something. Just thinking out loud...
__________________ Pete - X10 Oldie
|
Back to Top |
|
|
MrGibbage Super User
Joined: October 23 2006 Location: United States
Online Status: Offline Posts: 513
|
Posted: December 05 2012 at 04:24 | IP Logged
|
|
|
I actually write the results of that that command to the PH user log each time it
runs. By the way, I clear the event log each night, so I don't think it could be me
filling up the event log. Anyway, when this happens, there is nothing remarkable in
the log. One time it works, then the next time noting. Just the error message. And
from then on, just the error message.
By the way, overnight PowerHome's memory footprint increased to 42MB. Last night
before I went to bed it was at 32MB.
__________________ Skip
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 05 2012 at 10:31 | IP Logged
|
|
|
Skip,
I traced the sourcecode and this error is a result that is returned from the Catalyst HTTP control. This is a third party control that PowerHome licenses to do the URL queries and Im not sure why it would give an out of memory error.
Several things we can try. Since you're using the ph_geturl1 function, the second parameter (the 1 in your example in your first post in this section ...string(now())),1,20). Try changing it to a 0. This will still use a Catalyst control but instead of using the HTTP control it will use a raw socket. You can also use values of 2 and 3. Values 1, 2, and 3 all use the HTTP control. Values 1 and 2 are very similar so I would expect your problem to be solved by changing the 1 to either 0 or 3.
Give it a try and let me know how it goes.
Dave.
|
Back to Top |
|
|
MrGibbage Super User
Joined: October 23 2006 Location: United States
Online Status: Offline Posts: 513
|
Posted: December 05 2012 at 17:25 | IP Logged
|
|
|
If I set the second parameter to 0, I get an different error (right away)
An error occurred while processing the execution queue. Resetting execution queue
and trying again.
*** Error Details ***
Error Number: 39
Object Name: uo_socketblob
Class: uo_socketblob
Routine Name: f_geturl
Line: 51
Text: Error accessing external object property remoteport at line 51 in function
f_geturl of object uo_socketblob.
If I set it to 2, no error. Works fine.
If I set it to 3, no error. Works fine.
Since you suggested either 0 or 3, I will leave it on 3 for a while.
__________________ Skip
|
Back to Top |
|
|
MrGibbage Super User
Joined: October 23 2006 Location: United States
Online Status: Offline Posts: 513
|
Posted: December 16 2012 at 14:45 | IP Logged
|
|
|
Just updating here. I am still getting OOM errors, with both 0 or 3 for the last parameter. PH is
currently using 135MB, but it has been running for a full week in this OOM condition (I forgot to
check it for a few days). The memory usage just increases and increases, seemingly with each and
every call to ph_geturl1. After restarting PH, it is using only 35MB.
Running the request through curl works perfectly, except I don't like the popup command box. For
now, it would be helpful to know if there is a way to run an external command like curl, which is
a console program, without having the command window popup. Is there a windows trick, or a
powerhome trick, to make this happen?
__________________ Skip
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 16 2012 at 15:16 | IP Logged
|
|
|
Skip,
If PH is increasing in memory usage (and doesnt drop back down at some point when you minimize it), then you are suffering from the memory leak that the version 6 of the Catalyst controls has (the 3rd party control that PH uses for the ph_geturl functions).
I have verified that version 7 of the controls fixes the leak but we won't have it available until 2.1.5.
I know of no trick that will keep the console window from opening except to perhaps try creating a shortcut to run it minimized and then launching the shortcut. But then you wouldnt have the ability to pass the parameters necessary.
Did the other parameters in any way lengthen the amount of time before a restart was necessary?
Dave.
|
Back to Top |
|
|
MrGibbage Super User
Joined: October 23 2006 Location: United States
Online Status: Offline Posts: 513
|
Posted: December 17 2012 at 09:29 | IP Logged
|
|
|
No, changing the parameters don't seem to affect the amount of time before the error
occurs.
I think I am going to schedule a reboot each night to see if that keeps things moving
smoothly.
__________________ Skip
|
Back to Top |
|
|