?
Solved

CPU 100% usage VB6 app on Windows 2000 Machine

Posted on 2004-03-25
14
Medium Priority
?
427 Views
Last Modified: 2012-06-22
Based off previous question that I got a great answer from, I have around 30 forms and ADO's.  I have changed all my code to opend and close all the connections after they grab their data.  I am still getting machines that are locking up with 100% cpu usage.  I have changed the priorities for the app to high but I am still getting machines locking up.  There is nothing else on these machines although I did see a lot of services that have loaded.  What else can I look for?
0
Comment
Question by:sjmmajor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
  • 2
14 Comments
 
LVL 2

Expert Comment

by:robctech
ID: 10679587
Check any loops that you may have in your code and be sure you have DoEvents during long processing loops or timers which do extensive processing
0
 

Author Comment

by:sjmmajor
ID: 10679775
Thanks for your quick response.

I do have several timers.  So I need to put a DoEvents in those timer areas?  Within those DoEvents should I put the programing that I had in the timer event?

For example here is some code for one of them.

Private Sub Timer1_Timer()
On Error GoTo errorhandler

Adodc1.Recordset.Filter = adFilterNone
Adodc1.refresh
Adodc1.Recordset.MoveLast
frmfiringorder_5_21.Adodc1.Recordset.Filter = adFilterNone
frmfiringorder_5_21.Adodc1.Recordset.MoveLast
frmfiringorder_5_21.chartsection
Call totalLosses
Adodc1.Recordset.close
frmfiringorder_5_21.Adodc1.Recordset.close
   Exit Sub
errorhandler:
fCancelDisplay = True
ErrorNumber = 0
Err.Clear

Resume Next

End Sub

What do I need to do differently?  
0
 
LVL 2

Accepted Solution

by:
robctech earned 2000 total points
ID: 10679847
How often does this timer fire?

Additionally I would personally do something like below

Private Sub Timer1_Timer()
On Error GoTo errorhandler

Adodc1.Recordset.Filter = adFilterNone
Adodc1.refresh '//the refresh should be Automatic when you apply the filter
Adodc1.Recordset.MoveLast
frmfiringorder_5_21.Adodc1.Recordset.Filter = adFilterNone
frmfiringorder_5_21.Adodc1.Recordset.MoveLast
frmfiringorder_5_21.chartsection
DoEvents
Call totalLosses '//I'm Putting a doevent before and after as not sure what  
                       '//totallosses  does
DoEvents
'//Your closing the the recordset after timer...where are you actually opening it?
Adodc1.Recordset.close
frmfiringorder_5_21.Adodc1.Recordset.close
   Exit Sub
errorhandler:
fCancelDisplay = True
ErrorNumber = 0
Err.Clear

Resume Next

End Sub
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:sjmmajor
ID: 10679874
It fires about every 65 seconds.  This happens on 4 forms.  Others are hourly and others are 24 hours based off the system clock.

0
 
LVL 2

Expert Comment

by:robctech
ID: 10679947
Well I have never been a fan of ADO controls as they don't handle data communication very well.  the other thing you may wanna look into is using straight ADO connections so
you can open databases and then disconnect and store them....Can honestly tell you even just via your comments that your CPU usage sounds more connect disconnect refresh...sounds like much of it is result of constant opening and closing and scanning of databases...

For Example if you have a database that the data doesn't change very often then you could on load...

Global PrimaryConnection as ADODB.Connection
Global PrimaryRecords as ADODB.Recordset

Private Sub OpenPrimaryRecords()
      PrimaryConnection = '//put your connection string here
      With PrimaryRecords
            .CursorLocation = adUseClient
            .LockType = adLockBatchOptimistic
            .ActiveConnection = dbfConn
            .Source = '//Enter Your SQL String Here
            .Open
            .ActiveConnection = Nothing
End Sub

Now the database is replicated on the client machine...filters and moves execute much quicker as it doesn't have to actually go through the data connection to do what it wants..hopefull this makes sense to you and helps some of your problems
0
 
LVL 2

Expert Comment

by:robctech
ID: 10679986
I'll help you out on this as much as I can but sounds like its a pretty big project to make modifications to....and don't take this the wrong way but you may possibly want to look at making other major changes to the program if you can as it sounds as if there is alot of redundancy...(code written over and over...)

Anyways keep them coming and as I said help as much as I can
0
 

Author Comment

by:sjmmajor
ID: 10680040
I would still need the data refreshed.  I need to go out and get information that changes every 5 mins, every hour, every 24 hours.  How would I go about doing this?  Isn't it hitting the database just as much?
0
 
LVL 2

Expert Comment

by:robctech
ID: 10680070
5 minute timer
Private Sub DataRefreshTimer_Timer()
    PrimaryRecords.ActiveConnection = PrimaryConnection
    PrimaryRecords.Requery
End sub

1jr minute timer
Private Sub DataRefreshTimer_Timer()
    PrimaryRecords.ActiveConnection = PrimaryConnection
    PrimaryRecords.Requery
End sub

Etc....
0
 

Author Comment

by:sjmmajor
ID: 10680127
I will take a look.  Let you know in a while.  Thanks for your help.  If you think of anything else please let me know.

0
 
LVL 5

Expert Comment

by:g0rath
ID: 10680736
how large is the dataset that you are refreshing?
0
 

Author Comment

by:sjmmajor
ID: 10681031
I just change things to include the DoEvents and I am running a test through the night.  The database sets, I don't think are very big.  They can be up to about 144 rows and at the most 50 columns.  I purge every Saturday.  I have rolled out this program and then started getting the CPU 100% error.  I guess I finally added too much to the program.  But I do like the Global Connection.  I am just not sure how to do it.  What does Source capture?  Can you explain line for line what the above does?

I do appreciate everyones help.  
0
 
LVL 5

Expert Comment

by:g0rath
ID: 10681072
sometimes with too large of a dataset you need to implement your own paging. As in you only load the # of records you are really displaying.

So if you have 50K records but only show 10 at a time, then you just load 10, and remember where you are at...this is the way access does it....loading 10 at a time and only loading the next 10 when you move the scrollbar....

Here are various methods to help increase that area of performance....

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20175389.html?query=ado+paging+grid&searchType=all
0
 
LVL 2

Expert Comment

by:robctech
ID: 10681106
Explanation of Options

      .CursorLocation = adUseClient

Uses client-side cursors supplied by a local cursor library. Local cursor services often will allow many features that driver-supplied cursors may not, so using this setting may provide an advantage with respect to features that will be enabled. For backward compatibility, the synonym adUseClientBatch is also supported.

            .LockType = adLockBatchOptimistic

Optimistic locking, record by record—the provider uses optimistic locking, locking records only when you call the Update method.

            .ActiveConnection = This is your Dataconnection object

            .Source = '//Enter Your SQL String Here

Use the Source property to specify a data source for a Recordset object using one of the following: a Command object variable, an SQL statement, a stored procedure, or a table name. The Source property is read/write for closed Recordset objects and read-only for open Recordset objects.

Hope this helps
0
 

Author Comment

by:sjmmajor
ID: 10749580
Do events worked!!  Thanks.  One question though.  What is the rule of when to use Do Events?
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month15 days, left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question