Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QM hanging/frozen
#1
I run a macro frequently (thousands of times) but occasionally QM seems to just freeze with the QM icon pink (not blue) in the bottom windows toolbar to show it is still running but no further processing takes place.

I am happy there is not an infinite loop or a bug in the code and qm does not crash but just freezes.

Is there a way I can get qm to continue without pressing break and restarting the macro ? I do not want to do this as I lose data.

Any tips on solving this problem and identifying the cause would be appreciated.

Thank you
#2
Need the macro. Then possibly we can find a solution.
#3
[codeFunction outt
Code:
Copy      Help
/
function str'text


;Writes text to file "$my qm$\LogFileFast.txt". Appends newline.
;This function is fast, faster than out. Writes to file asynchronously, every 1 s and when QM exits.
;Deletes old file when called first time in current QM session.
;To change file, edit this function. Or execute this when QM starts, before calling this function first time: str+ g_LFF_File="C:\...\your file\txt"


lock _LogFileFast
str+ g_LFF_File __LFF_Buffer
int+ __LFF_Thread
__Handle+ __LFF_Event

if !__LFF_Thread
,if(!g_LFF_File.len) g_LFF_File="$my qm$\mydata\LogFileFast.txt"
,if(FileExists(g_LFF_File)) del- g_LFF_File; err out "Error in LogFileFast: failed to delete old file."
,__LFF_Buffer.flags=3
,__LFF_Event=CreateEvent(0 0 0 0)
,__LFF_Thread=10
,mac "sub.Thread"

__LFF_Buffer.addline(text)

lock- _LogFileFast
if(__LFF_Buffer.len>4000000) SetEvent __LFF_Event; 0.001


#sub Thread
atend sub.Atend
rep
,wait 1 H __LFF_Event; err
,if(__LFF_Buffer.len) sub.WriteToFile


#sub WriteToFile
lock _LogFileFast
__LFF_Buffer.swap(_s)
lock- _LogFileFast
_s.setfile(g_LFF_File -1); err out "Error in LogFileFast: failed to write to file."


#sub Atend
if(__LFF_Buffer.len) sub.WriteToFile
][/code]
#4
Difficult. Are you sure that the macro is executing this function when freezes? Try to use function LogFile instead.
#5
Yes I believe this is the function which is being executed when QM freezes.

It happens very rarely and I execute that function thousands of times often many times per second without it freezing.

I will experiment with LogFile but I just need something with writes to a file fast.
#6
This is not as fast as LogFileFast, but much faster than LogFile.

Function LogFileFaster
Code:
Copy      Help
;/
function str'text

;Writes text to file "$my qm$\LogFileFaster.txt". Appends newline.
;Deletes old file when called first time in current QM session.
;To change file, edit this function. Or execute this when QM starts, before calling this function first time: str+ g_LFF_File="C:\...\your file.txt"
;Faster than LogFile which opens and closes the file each time. This function opens the file when called first time, and it is closed when QM exits or opens another QM file.

;Tested speed:
;When called very frequently - 9 mcs with cold CPU, 1 mcs with warm CPU.
;When called after some time - 30-60 mcs with cold CPU, 10-30 mcs with warm CPU.
;LogFile speed is > 100 mcs.


opt noerrorshere 1
str+ g_LFF_File
__HFile+ __LFF_HFile
if !__LFF_HFile
,lock
,if !__LFF_HFile
,,if(!g_LFF_File.len) g_LFF_File="$my qm$\LogFileFaster.txt"
,,__LFF_HFile.Create(g_LFF_File CREATE_ALWAYS GENERIC_WRITE FILE_SHARE_READ) ;;error if fails
,lock-

text+"[]"
if(!WriteFile(__LFF_HFile text text.len &_i 0)) end "failed" 8|16 ;;warning if fails

;WriteFile does not write to disk immediately. It writes to a file buffer in memory, which is regularly written to disk, maybe every several seconds.
#7
Brilliant thank you.

I will test this code and see how it performs
#8
i have the same problem


Forum Jump:


Users browsing this thread: 1 Guest(s)