PDA

View Full Version : Resource Hog?



fgasoi
06-10-2011, 19:55
I installed yesterday a small bundled app on one of the older computers on our LAN. One of its users complained this morning that its response was "glacial". I ran Task Manager and found that the app itself took 0 CPU time, but Thinbasic.exe took on average 70% of CPU time, with a peak of 83%! This machine is running WIN XP SP3 on a 2.4GHz Pentium with 512MB RAM and a 40G hard disk. The RAM is admittedly small, but is this normal?

Rick

ErosOlmi
06-10-2011, 21:37
Hi Rick,

bundled EXE are not real executables but are more like a ZIP file.
When you run a bundled EXE, it extracts on disk a bundled version of thinBasic.exe, than thinBasic.exe is invoked in order to execute real script.
So the running real application is thinBasic.exe and it is normal to see CPU allocated to thinBasic.exe and not to your bundled exe name.


About CPU usage, it really depends on how you wrote your script.

For example:
If you create a loop inside which you do something contiguously without giving some free time to the processor ... it is quite normal you will follow into heavy CPU usage.
The same if you do TBGL loops without using timers.
The same if you have a UI and you use loops without using timers.

So, it is hard to understand from outside why your CPU is so high without having some example to check and explain the logic of the application.

Ciao
Eros

fgasoi
11-10-2011, 15:22
That's exactly what it is doing, Eros. I will put in a SLEEP to pace it. Thanks.

Rick

ErosOlmi
11-10-2011, 21:34
If there is an indicative piece of code that you can post showing the loop creating the CPU usage I can try to check

zak
12-10-2011, 06:33
i have faced this before in this thread... (http://www.thinbasic.com/community/showthread.php?9561-Plotting-Slowly&highlight=doevents) , and using DOEVENTS inside the loop relief the possible freezing the program

fgasoi
12-10-2011, 22:43
Here is the piece of code, as modified with a 100msec sleep. CPU usage now unmeasurable.


Do
NBytes = COMM_Get ( hcomm, %COMM_RXQUE )
If NBytes => 21 Then
COMM_Recv ( hcomm, NBytes, InBuff )
Exit Do
EndIf
If Len ( Console_InKeyB ) > 0 Then
Console_Cls
Console_PrintAt ( "ABORTED BY USER", 32, 12 )
Console_WaitKey ( 3 )
COMM_Close ( hcomm )
Stop
EndIf
Sleep (100)
Loop