WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

FAQs - Frequently Asked Questions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Winbatch Overhead and Resource Usage

Keywords:     resource usage  kernel32.exe  resource leak

Question:

I've been evaluating WinBatch (and the Control Manager extender), writing scripts to "babysit" batch applications running unattended under Windows NT. To justify a purchase decision, I need to document the overhead (resource usage, DLLs open, etc.) that WinBatch will add to the system.

I am working under WinNT 4.0.

Can you give me an idea (as detailed as practical) as to the additional resource drain that WinBatch/Control Manager will impose?

Answer:

  1. When WinBatch is not running, it merely occupies a few MB of disk space - This includes help files etc etc. It does not sit around in memory tieing up resources.

  2. The presence of the Control Manager extender adds negligible overhead to Winbatch.

  3. WinBatch itself, when running, occupies maybe 3MB of memory. Most scripts would stay in about this range, although you can write scripts to allocate more memory. This amount is usually negligible on most running Windows platform and the swap file can expand the physical memory available. You could see an impact on a 4MB machine. (It would barely run Windows anyway)

  4. When running WinBatch needs processor time. When waiting (RunWait TimeDelay etc) WinBatch chews up a minimal amount of processor time - and actually spends its processor time trying to give it away. CPU meters can be fooled by this behavior - If no other processes are running, it looks like WinBatch is chewing up all the processor time - the problem is that it does not have anyone to give it away to - a real-life test of someone sitting in front of the machine trying to do something is more of a reliable indicator than a CPU meter.

    WinBatch does sometimes have a "polling" mode where it can spend a lot of CPU time trying to give CPU time to other applications. This fools most CPU meters. The real test is to run Word for Windows or Excel or something and see if you can notice any difference.

  5. There is a resource problem when running 16 bit WinBatch on a 32 bit machine. Although it works, it does indeed burn a lot of cpu time in any of its delay or wait states. So if using 16-bit WinBatch on an NT system you will see a lot of problems involving 100% cpu usage. This is the most common cause of high resource usage. We recommend 32 bit WinBatch for 32 bit OS's

  6. Make sure "Exclusive(@ON)" has not been used.

    It is quite difficult for 32 bit WinBatch with the default setting of Exclusive to reach 99% CPU utilization. There are built in 20 millisecond delays between every statement. This tends to bring average CPU usage down to about 20% when the machine is running. Lower for faster machines.

  7. Also might be worth doing a Timedelay (0.1) just before the goto. This seems to cut down CPU dramatically.

Related Question:

I have created (my first) wbt-file for a everlasting check on the existence of a file on a file server. When the file exists a certain job is to be done (once a day). The process runs under NT4. When the process is started is seems like it takes all the CPU power. Can I do the same job in a different way?

Answer:

Yes, you are using most of the CPU. Add a TimeDelay in, instead of the Strsub, as follows.

Just check once every 600 seconds should do it. You probably also want RunWait instead of Run.

fortsett = @true
while fortsett == @true
   TimeDelay(600)
   if FileExist("k:\cr10\gif\gifklim.flg")
   RunWait("gif_kopi.bat", "")
   FileRename("k:\cr10\gif\gifklim.flg", "k:\cr10\gif\gifklim.fl-") 
   endif
endwhile
return

Another Related Question (100% CPU on NT):

Should my script be using 100% of CPU when I put it in the TaskTray using IntControl 1007?

Command is as follows:

	IntControl(1007, 1, 3, "Select Case by ID", "c:\compass\compass.ico") 

Answer:

Depends. Most of the CPU meters lie. Basically fire it up and try and use windows. Edit a document. Recalc a spreadsheet. See if you notice performance degradation.

Question (cont'd):

No, it's not a lie. Has something to do with the option to suspend the script until the user clicks on the tray icon. While it is in this waiting mode it uses 100% of CPU according to the NT TaskManager. It is preemted by other tasks as they become active but, I don't believe the behavior is "normal". At least none of the other TaskTray icons use 100% CPU.

Answer:

We can add some code to make NT Task Manager look better. Probably in the next release (98F).

Related Question (CPU Maxed Out):

I'm using (trying) WinBatch 95 (version 95) and I'm having something funny happpen when I run my program. This is my first program!!. The program does execute properly from start to finnish, but what I have noticed is that when I use this program , my CPU usage is maxed out. If I open the programs manually , the CPU is at normal use. Below is a copy of the program , is there something wrong in the way I wrote it, or is the CPU usage really not maxed out, but just getting some type of false reading??.
;Log on to Internet Program
;Created 1\5\97
;use to load up then close Programs to go on line with

RunShell("C:\Vs95\Vswatch.exe", "", "", @normal, @nowait)
RunShell("E:\Software\interlog\interlog.exe", "", "", @normal, @nowait)
Run("csinsm32.exe", "")
;the next command is used to hold up the program
;untill you close I-explorer 
RunWait("Iexplore.exe", "")

;this next section will close some of the programs
Display(3,"MEASAGE","Virus Scan Will Not Be Closed")

WinClose("CleanSweep Deluxe Smart Sweep/Internet Sweep")
WinClose("Internet LogMeter") 

Answer:

Assuming you are using a 32 bit version of WinBatch, you are getting a false reading from the CPU meter.

Try just doing anything. Does the system seem reasonably responsive? Web pages download, etc. etc.

What is happening is the WinBatch (During the RunWait) spends all of its CPU time trying to hand it off to other programs. The system is trying to hand CPU time to WinBatch and counts that as busy, but WinBatch just lets it flow thru.

Not sure if you've done this but there is a patch on the Microsoft ftp site to correct memory leaks. You download the kernel32.exe file and it is supposed to fix slow resource leaks.


Question:

All of the sudden my Winbatch is very slow (wbt files). Its like all my winbatch files have a 10 sec delay before they start working. I've installed a couple new programs, like Adobe Illustrator, & Director. Any idea what to do???

This is an extremely fast computer with NT 4.0 and I'm not running anything when I run a winbatch file.... I'm not using any system tuneup utilities.

Answer:

Not sure. Most of the time this is a system configuration setting where the foreground all gets almost all the processing time and the background apps (usually WinBatch) hardly get any. (Or a DOS window sucking up CPU cycles.)

But it sounds like a configuration setting.

Try this:

Start Control Panel. Select the system applet. Select the performance tab. Is the little slider pegged to the right? Move it to the middle. Test.

Also might try:

Ctrl=Alt-Delete -> Task List -> Processes and see WHAT is chewing up CPU time.

Question (cont'd):

>Is the little slider pegged to the right?
Yes
>Move it to the middle.Test.
No difference
>Also might
>Ctrl=Alt-Delete -> Task List -> Processes >and see WHAT is chewing up CPU time.
I using this script...
   PlayWaveForm ("PHONE.wav", 0)
   RUN("C:\progra~1\phone\PHONE-F4.CRD","")
   WinPlace(80,80,260,800, "Cardfile")
   SendKeysTo("Cardfile","{f4}")
The PlayWave works immediate, the Run works immediate, but the SendKeysTo starts in 10 secs. If I open the program and just run the SendKeysTo then it still takes 10 secs before it starts.

I Looked at my Performance and for 10 secs it shows zero and then goes to 20% to SendKeysTo.

Any ideas now???

Answer:

  1. Try commenting out the WinPlace. Basically it will wait for maybe 8+ seconds for the Cardfile window. Does the Window place immediately?

  2. Try intControl(43,0,0,0,0) and see if that helps.

    Basically the intControl(43,0,0,0,0) disables the automagic Sendkey pacing.

    To do that trick we need access to a very particular part of the registry. And it is easy to do it wrong. I suspect one of the other programs you have running all the time has grabbed that section of the registry and is holding onto it for dear life, so SendKey tries to get it, and times out after 10 seconds.

    HKEY_DYN_DATA is the key in the registry. RegEdit generally does not show it to you.

  3. I would look *very* carefully at anything that kind of runs all the time. PC Anywhere have a little applet watching the phone?

  4. Also sometimes performance monitor programs blow it.

  5. Ctrl-Alt-Delete / Tasklist. Understandf all the contents. Expecially recently added stuff.

    Basically, to solve the puzzle, you do a Ctrl-Alt-Delete, get to the tasklist and try to understand everything in there. Something there is likely causing the problems.


Article ID:   W13006
Filename:   WinBatch Overhead and Resource Usage.txt
File Created: 2001:01:03:12:06:48
Last Updated: 2001:01:03:12:06:48