Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disappearing program mystery 1

Status
Not open for further replies.

Geofs

Programmer
Mar 3, 2010
9
US
I have a small VFP9 program that is supposed to run 24/7 on a workstation to import data from text files that are sporadically generated by another program. It uses a timer to check for these text files on a user-defined schedule. Occasionally, this program just disappears from the workstation without making the normal 'shutdown' entries into its log file. There are also no log entries indicating any error. The program will run for one day, or two, or three, then go away. The time-of-day doesn't seem to matter either. What's more, the other program (a non-VFP application), which is running on the same workstation, is still there.

I've made sure that the VFP DLL's are up-to-date and deleted all 'FoxUser.*' files. I've confirmed that the only QUIT or CANCEL command is the one in the shutdown procedure. (The program is normally shut down via a 'Quit' button which releases the form. The main program then closes tables and calls the shutdown procedure.)

By adding log entries and LIST MEMORY commands to various spots in the program, I've confirmed that it's always (at least so far) in the timer code when it goes away. However, that isn't surprising because that's where it spends virtually all of its time, checking the clock once per second and waiting for the next scheduled import time. I haven't yet seen an instance where the program disappears during the actual import process.

There's no reference to this event in either VFP9Rerr.LOG or the Windows logs, either.

Does anyone have any other suggestions on how to track down the gremlin that's causing this program to disappear without a trace?
 
I wrote a similar app in VFP 5 some years ago and had the same problem. I ended up resoving it by doing away with the timer and using the Windows task scheduler instead. Worked like a charm and it took only minutes to implement. Just wasn't worth the time it was going to consume tracking down the actual culprit.

- Fast, Easy, Reliable and Affordable Hosting
 
Thanks for the suggestion. Do you thing the Task Scheduler would be appropriate for firing off a program every 30-60 seconds?
 
My application only required updates every 5 minutes. Don't know about shorter intervals. You could always use a hybrid approach or use the task scheduler to monitor and restart your app if needed as well.

- Fast, Easy, Reliable and Affordable Hosting
 
Do you thing the Task Scheduler would be appropriate for firing off a program every 30-60 seconds?

If you are referring to the Windows Task Scheduler, the answer is No. You can fire tasks only where the task interval is a multiple of one day (or when the system is idle). (At least, that's true in XP; I don't know about other versions).

But there are presumably other ways of firing a task at frequent intervals.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
That's incorrect. The windows task scheduler can fire tasks at intervals down to one minute intervals. First create the task and specify one day intervals, then open the task, go to the Schedule tab and click the Advanced settings button. Then tick the Repeat checkbox and specify the interval you want down to one minute increments. You can even specify the duration the task should run and optionally stop the task if it exceeds the specified duration.

- Fast, Easy, Reliable and Affordable Hosting
 
Thanks for your suggestions, guys. I'd really like to find out what's knocking this program out of the box and then fix it in order to keep things simple. But, since it seems like that's not going to be possible, the Task Scheduler should at least provide a way to make sure the program is restarted from time to time.
 
I've had this happen with service apps.

Its hard to combat.

first thing I'd do is make sure you timer can never fire while the code it fires is running.

Next create your own log file writing to it after each major step has been completed. If you have an error handler make it write to the log as well. Make sure you put pertinent values in the log file so you can see what data is being processed at any point then you can try to back into what it was doing when it dies.

Alan
 
It could be that your files are being placed on the drive, but buffers aren't being flushed before the fox app is trying to import them if you're checking for their existence that often.

I have apps running that have timers that fire and run processes akin to what you're doing. They will run for weeks or months without an issue.

One thing I do in the timer event to ensure it doesn't fire multiple times while processing is at the beginning of the event, I first save the interval to a variable. I then set the interval to 0, then restore the interval back to what the variable value is at the end of the event code.

But every second seems like overkill to me. Every minute or so, or even every 5 or 10 seconds should still be sufficient.




-Dave Summers-
[cheers]
Even more Fox stuff at:
 
One thing I do in the timer event to ensure it doesn't fire multiple times while processing is at the beginning of the event, I first save the interval to a variable. I then set the interval to 0, then restore the interval back to what the variable value is at the end of the event code.

Another way of achieving the same goal would be to disable the timer at the start of the event, and re-enable it at the end.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
I would follow Mikes advice re disabling the timer and reenabling it at the end of the event code.

I would also suggest that you count the number of time you process whatever you are doing and then, after say 50 iterations, reload the application automatcially and let it release any memory as the original version quits - you can do this quite easily with a shellexecute call.

B-)

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Thanks to all you guys for your suggestions. I hadn't thought of disabling the timer while the program is off doing something else. I just figured that, since it passes control to a different function, it sits and waits for that function to finish. I'm going to try disabling the timer to see how that affects the situation.
 
...reload the application automatcially and let it release any memory as the original version quits...
While that does indeed do the trick, I prefer using the API calls to reduce/empty residual memory, which will probably eliminate the need for restarting the app:

GetCurrentProcess()
SetProcessWorkingSetSize()

These seem to work quite well. Especially when third party or non-VFP controls are involved.
If anyone wants a better example, I can post it.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
I have those as well, but I have one 3rd party thing that just hogs memory! so exit and reload is good for me - it also give a chance to auto update!


Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
no matter how hard i try or how good the app is, every once and awhile i will have one that just dosn't play nice and does whatever it wants. For these instances i use a program called AlwaysUp from it is inexpensive and does the trick everytime. It will setup my application as a service and give control over how and when it starts and how it should handle when it quits LIKE RESTART it can run batch files before it starts for cleanup stuff. As well as what to do if it is hung or being a cpu hog. Saved my reputation many times over.


Steve Bowman
Independent Technology, Inc.
CA, USA
 
Thank you for the suggestion, Steve. I'm going to download AlwaysUp and give it a try.
 
And thanks to everyone who made suggestions. I've modified the program to disable the timer while it is off doing some work and added a call to SetProcessWorkingSetSize() to reduce the memory footprint of the program every 24 hours. I'm monitoring the situation to see whether or not these changes help.

Thanks again.
 
You will find that the AlwaysUp is a very well coded piece of work and does what the name implies everytime. Look through the different options. It will even allow for dependent services. Where my app will not start before another selected service is operational. For me in cases of 24x7 being critical i will use the Always up even if my Application is behaving correctly. it covers me when an unknowing user shuts down the app without asking. It will send emails out when the app restarts. For me when someone wants a 24x7 I just build in the price of a license. Thanks.


Steve Bowman
Independent Technology, Inc.
CA, USA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top