Application freezes randomly - no error message

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
zolysoftsolutions
Posts: 139
Joined: Wed Feb 29, 2012 3:33 am
Location: Gyulakuta, Erdélyország
Contact:

Application freezes randomly - no error message

Post by zolysoftsolutions »

Hi my friends,

I made a complex restaurant sale system.

As normal, I have defined many labels, buttons and a grid as neccessary.
I am using MySql database - like this: TMySQLServer():New(host,user,passw)
I printing to several thermal printers (lan) installed on Windows calling them by "Select printer ..."
I have defined a timer to refresh the occupied tables state.

I tried to keep connected to database during all working session.
I tried to connect to database each time I needed.
I tried to use database directly on workstation (to eliminate lan problems)
I increased the timers period to 5 minutes.

I rewrote all the code in without any copy-paste, same problem.

THE PROBLEM: sometimes the application freezes randomly, NOT ON SAME PROCEDURE. Many times when label's action executed (click on).
But the symptoms are the same: All controls on display becomes white, sometimes the bacground become white,somethimes transparent with black border of form window, but the controls responds if I click on the zone where the control should be visible.
Very curios is that somethimes 15 hours we use the application without a single freeze, and on other days freezes even 5-6 times.

Do somebody meet this problem?
Is an easier way to print to thermal printer instead of select printer, open printpage etc..?
I another way to connect to a mysql database instead of TMySQLServer() ?

Best regards,
Zoli B.
_______________________________
Open eyes for you!
User avatar
serge_girard
Posts: 3167
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Application freezes randomly - no error message

Post by serge_girard »

Zoli,

I remember having this also one time. Can't think of the cause right now but to find problem is not impossible.

This is how I would try to solve it:

At the top of your program:

Code: Select all

SET PRINTER TO problem.txt // or whatever
SET PRINTER ON 
SET CONSOLE OFF
Then in every function/proc, after declaring locals: ? procname(), time()
Maybe someothers at certain points that might be suspicious.

Recompile and run. When it freezes, kill the program with taskmanager and check the problem.txt file.

This will surely help you, it helped my lots of times!
When no succes, send sources (if you want to)

Serge
There's nothing you can do that can't be done...
User avatar
serge_girard
Posts: 3167
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Application freezes randomly - no error message

Post by serge_girard »

BTW I use TMySQLServer for many years now, without problems.
For your question about printers cannot help.

Serge
There's nothing you can do that can't be done...
User avatar
zolysoftsolutions
Posts: 139
Joined: Wed Feb 29, 2012 3:33 am
Location: Gyulakuta, Erdélyország
Contact:

Re: Application freezes randomly - no error message

Post by zolysoftsolutions »

Thank you very much Serge,
It's a great ideea to log the activity.
Zoli B.
_______________________________
Open eyes for you!
User avatar
serge_girard
Posts: 3167
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Application freezes randomly - no error message

Post by serge_girard »

Let me know when you found the problem!
Serge
There's nothing you can do that can't be done...
User avatar
zolysoftsolutions
Posts: 139
Joined: Wed Feb 29, 2012 3:33 am
Location: Gyulakuta, Erdélyország
Contact:

Re: Application freezes randomly - no error message

Post by zolysoftsolutions »

Hi Serge,

I found a lot of problems, a lot of unneccessary procedures :)
BUT, I think I found also the problem causes freezeng:

In app when the waiter picked a group of products, a procedure starts to show the items:
- first: I set the backcolour, fontcolor, fontbold, visible of 30 labels (for products in the group)
- second: read in an array the products of the group from database
- third: set value of the labels from array (depends of the lenght of array)
- fourth: the rest of labels to 30, invisible
An another procedure, when the waiter clicked a product, the corresponding label has coloured in other color and the product was dropped in grid.

The problem was coloring the background of the labels in a for..next statement in first part of the procedure.

Code: Select all

For i:=1 to 30   && I think here is the problem 
 xlab:='lav'+alltrim(str(i))
 setproperty('main',xlab,'backcolor',{200,200,200})
next
Solution: I set the properties of labels during definition, and avoid to change any color runtime. The app runs smoothly, no freeze yet (in last 8 hours).

Thank you very much for your help.
Zoli
_______________________________
Open eyes for you!
User avatar
serge_girard
Posts: 3167
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Application freezes randomly - no error message

Post by serge_girard »

A simple solution! I use it many years and helped me always!
And when it works I just comment the ? commands with // for reuse later...

I'm glad your app is now running smoothly.

Serge
There's nothing you can do that can't be done...
franco
Posts: 821
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Application freezes randomly - no error message

Post by franco »

Zoly, for thermal printer on workstation I make the thermal printer the default printer. It makes it easier for me.
I also have 5 printer names in my control table which is also open pr1, pr2........... with shared names
Then
procedure prtherm
local lsuccess
select printer default to lsuccess // you could also used shared name pr?
orientation .... and so on.
if lsuccess <> .T.
error
return
endif
start printdoc
Hope this is what you where looking for, seems to work go for me in gas bars.
Franco
All The Best,
Franco
Canada
User avatar
zolysoftsolutions
Posts: 139
Joined: Wed Feb 29, 2012 3:33 am
Location: Gyulakuta, Erdélyország
Contact:

Re: Application freezes randomly - no error message

Post by zolysoftsolutions »

Hi Franco,

Thank you very much trying to help me.
The "lSuccess" will return False just when the printer is NOT INSTALLED.
In case is installed, and is a paper jam error, for sure the code will continue to run without any problems, and all the document will wait in queue of the printer spooler (under Windows). lsuccess will return .T.
Eventually in some way we have to ask Windows about the printer status, but I don't know how to do it.. where Windows keep these informations.

Regards,
Zoli B.
_______________________________
Open eyes for you!
franco
Posts: 821
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Application freezes randomly - no error message

Post by franco »

I believe lsuccess tells us printer is ready. I will test and put printer on standby to see what happens and let you know.
Franco.
All The Best,
Franco
Canada
Post Reply