KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

Excessive CPU usage

 
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion
View previous topic :: View next topic  
Author Message
AJ83
KiXforms Follower
KiXforms Follower


Joined: 14 Jun 2007
Posts: 16

PostPosted: Tue Nov 13, 2007 4:38 pm    Post subject: Excessive CPU usage Reply with quote

Hi,

I built a pretty neat 6000 line program in kixforms.net to process information from a PDF (scanned mail) into an SQL database.

Some of the information has to be chosen from pre-filled comboboxes (Extracted from SQL databases at program start)
Some information entered is validated against SQL databases.
Some information has to be searched for(Query`s to sql databases, with results in listview)

Today i noticed that the program constantly uses 1,5Ghz of CPU. Which is quite strange since it isn`t doing things all the time.

My first hunch is that it might be something to do with the sql communication, but everytime i use sql comminication, i open a connection, query, and close the connection.
But if this was the problem, you would expect the cpu usage to rise after using some more sql based functions, but this isn`t the case. The usage stays on a steady 50% on my 3Ghz machine.

What can be the cause of such behaviour? Can constant refresh of the interface be the culprit? The interface is quite complicated, it is 1024x768 Full screen, wich can slide to reveal another large portion of interface, and 2 extra search popups (see attached image)



Screenshot_V1-80 (Medium).jpg
 Description:
Screenshot of all parts of the interface
 Filesize:  98.52 KB
 Viewed:  2458 Time(s)

Screenshot_V1-80 (Medium).jpg


Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Thu Nov 15, 2007 4:03 pm    Post subject: Reply with quote

Wow - what a cool looking application. Are you using any DoEvent(0) method calls ?

-Shawn
Back to top
View user's profile Send private message
AJ83
KiXforms Follower
KiXforms Follower


Joined: 14 Jun 2007
Posts: 16

PostPosted: Sun Nov 18, 2007 5:57 pm    Post subject: Reply with quote

Shawn wrote:
Wow - what a cool looking application. Are you using any DoEvent(0) method calls ?

-Shawn

I don`t, should i?
Im not really up to speed regarding this command.
Could i use DoEvents(1) to make the application keep responding after starting a sql query? Now the application is unresponsive untill the result of the query is loaded into the listview.

Maybe the problem is just the fact i built a complicated application in a script language Wink
Back to top
View user's profile Send private message
Sealeopard
KiXforms Aficionado
KiXforms Aficionado


Joined: 05 Mar 2003
Posts: 436
Location: Boston, MA

PostPosted: Mon Nov 19, 2007 1:31 am    Post subject: Reply with quote

The main problem is that the KiXtart script will not continue until the query is finished. One way to solve that would be to build something asynchronous, i.e. run the query in a separate KiXtart thread, then integrate the resultset back into the main script. doable, but complex.
_________________
Jens

'There are two kinds of vessels, submarines and targets.'
Back to top
View user's profile Send private message Send e-mail MSN Messenger
AJ83
KiXforms Follower
KiXforms Follower


Joined: 14 Jun 2007
Posts: 16

PostPosted: Tue Dec 11, 2007 4:29 pm    Post subject: Reply with quote

The problem was indeed the $=Execute($MAIN_Form.DoEvents(0)) pretty stupid i didn`t notice b4.

How does using this make kix32.exe use so much cpu?
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Tue Dec 11, 2007 5:42 pm    Post subject: Reply with quote

Because DoEvents(0) returns immediately - even if there are no events in the event queue - basically its like an endless loop - what I usually do is put the following statement...

Sleep 0.100 ; msecs

...right after the DoEvents line inside the loop. Adjust the time up or down for best results. This frees-up your cpu and gives other processes a time-slice.

-Shawn
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group